From f90c1adb2a8689e3387071320f6a3bb51fa28e5f Mon Sep 17 00:00:00 2001 From: ilyaigpetrov Date: Sun, 21 Sep 2025 11:00:32 +0500 Subject: [PATCH] Add urls of actual pac scripts to the interface. Experiment with native components --- src/pages/options/bottom.mjs | 1 + src/pages/options/components/PacRecord.html | 35 ++ src/pages/options/index.html | 146 ++------- src/pages/options/old-index.html | 336 ++++++++++++++++++++ src/pages/options/pacRecord.html | 36 +++ src/pages/options/top.mjs | 249 +++++++++++++++ 6 files changed, 679 insertions(+), 124 deletions(-) create mode 100644 src/pages/options/bottom.mjs create mode 100644 src/pages/options/components/PacRecord.html create mode 100644 src/pages/options/old-index.html create mode 100644 src/pages/options/pacRecord.html create mode 100644 src/pages/options/top.mjs diff --git a/src/pages/options/bottom.mjs b/src/pages/options/bottom.mjs new file mode 100644 index 0000000..858824b --- /dev/null +++ b/src/pages/options/bottom.mjs @@ -0,0 +1 @@ +console.log('The BOTTOM script of the options page started.'); \ No newline at end of file diff --git a/src/pages/options/components/PacRecord.html b/src/pages/options/components/PacRecord.html new file mode 100644 index 0000000..12c8e00 --- /dev/null +++ b/src/pages/options/components/PacRecord.html @@ -0,0 +1,35 @@ + + + + + ID + VALUE + FOR + LABEL + + + - - -
  • - - -
    - -
    - -
    -
    - - -
    -
  • - - + + + +
  • +
  • +
  • @@ -331,6 +229,6 @@ href="https://github.com/anticensority/runet-censorship-bypass/wiki/Поддержать" >Donate ❤ - + \ No newline at end of file diff --git a/src/pages/options/old-index.html b/src/pages/options/old-index.html new file mode 100644 index 0000000..dfa9411 --- /dev/null +++ b/src/pages/options/old-index.html @@ -0,0 +1,336 @@ + + + + + + + + +
    + PAC-скрипт: +
    + + + + + \ No newline at end of file diff --git a/src/pages/options/pacRecord.html b/src/pages/options/pacRecord.html new file mode 100644 index 0000000..fbab06c --- /dev/null +++ b/src/pages/options/pacRecord.html @@ -0,0 +1,36 @@ + + + + + ID + VALUE + FOR + LABEL + + + + + + [обновить] + [⏸] + [ℹ] + + + + + + antizapret + antizapret + + + + \ No newline at end of file diff --git a/src/pages/options/top.mjs b/src/pages/options/top.mjs new file mode 100644 index 0000000..e6e6b1e --- /dev/null +++ b/src/pages/options/top.mjs @@ -0,0 +1,249 @@ +console.log('The TOP script of the options page started.'); + +/* + + Антизапрет + +*/ + +customElements.define('pac-record', + class extends HTMLElement { + + static formAssociated = true; + // static observedAttributes = ['data-checked']; + + constructor() { + super(); + this.internals = this.attachInternals(); + const shadow = this.internals.shadowRoot; + console.log('Constructor for PacRecord'); + } + } +); + +/* + + + + + + + + + + + + antizapret + antizapret + +Антизапрет + + +class extends HTMLElement { + static formAssociated = true; + // static observedAttributes = ['data-checked']; + constructor() { + super(); + const shadow = this.attachShadow({ mode: 'open' }); + // const shadow = this.internals.shadowRoot; + console.log('Constructor'); + const fragment = pacRecordTemplate.content.cloneNode(true); + shadow.appendChild(fragment); + this.internals = this.attachInternals(); + + const dataAttrs = shadow.querySelectorAll('*[data-attrs]'); + dataAttrs.forEach( + (da) => { + da.dataset.attrs.split(' ').forEach( + (attr) => { + console.log(shadow.querySelector(`#VARIABLES > slot[name=${attr}]`)); + da.setAttribute( + attr, + shadow.querySelector(`#VARIABLES > slot[name=${attr}]`).assignedNodes()?.[0]?.textContent, + ); + }, + ); + } + ); + //this.internals.setFormValue(''); + //this.internals.setFormValue('pacScript'); + //const templateAttrs = shadow.querySelectorAll('#attributes > slot[name]'); + const namedInputs = shadow.querySelectorAll('input[name]'); + console.log('NAMED INPUTS:', namedInputs); + namedInputs.forEach((ni) => { + //this.internals.setFormValue(ni.name); + ni.addEventListener('input', + (event) => { + const t = event.target; + const entries = new FormData(); + //entries.set(ni.getAttribute('name'), ni.getAttribute('value')); + entries.append('pacScript', t.value); + this.internals.setFormValue(entries); + //this.value = t.value; + //this.internals.setFormValue(t.value); + //ni.toggleAttribute('checked'); + //this.internals.setFormValue(ni.value); + //this.toggleAttribute('checked'); + //this.toggleAttribute('data-checked'); + //ni.toggleAttribute('checked'); + console.log('EVENT TARGET:', event.target); + console.log('THIS', this); + console.log(this.internals); + console.log('EEEE', Array.from(...entries)); + console.log(`FFFF:${ni.name}=${ni.value}`); + ni.click(); + }) + }); + + / + const input = fragment.querySelector('div > input'); + const label = fragment.querySelector('div > label'); + /*const node = pacRecordTemplate.content.cloneNode(true); + const input = node.querySelector('div > input'); + const label = node.querySelector('div > label'); + input.id = input.value = label.htmlFor = this.dataset.id; + / + + } + attributeChangedCallback(name, oldValue, newValue) { + console.log('attributeChangedCallback:', oldValue, '->', newValue); + const entries = new FormData(); + entries.set('pacScript', 'antizapret'); + this.internals.setFormValue(entries); + } + } +); +/* + + +``` + + + + + + + + antizapret + antizapret + + Антизапрет + + + + + + + anticensority + anticensority + + Антицензорити + + + + +``` \ No newline at end of file