mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-15 04:40:01 -04:00
Updated Options Menu Schript
-- Contribution from YÖCTDÖNALD'S
This commit is contained in:
parent
91e88ad4c9
commit
edd10e6206
1 changed files with 17 additions and 20 deletions
|
@ -2,44 +2,41 @@
|
|||
let titles = icons = [];
|
||||
|
||||
addEventListener('DOMContentLoaded', p => {
|
||||
p = $('csel');
|
||||
setPreferences();
|
||||
setPreferences(p = $('csel'));
|
||||
titles.forEach((e, i) => p.innerHTML += i ? `<img title="${e}" src="${icons[i]}">` : '<img title=(Blank) src=./img/x.png>');
|
||||
|
||||
/*Title Submit*/
|
||||
/*Submit Title & Icon*/
|
||||
(i => i.onsubmit = e => e.preventDefault() || setTitle(i.firstChild.value || '‏‎'))($('titleform'));
|
||||
|
||||
/*Icon Submit*/
|
||||
(i => i.onsubmit = e => e.preventDefault() || setIcon(i.firstChild.value || 'data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAA'))($('iconform'));
|
||||
|
||||
/*Settings Submit*/
|
||||
/*Submit Settings*/
|
||||
p.onclick = (e, s) => (s = Array.from(p.children).indexOf(e.target)) + 1 && setTitle(titles[s], setIcon(icons[s]));
|
||||
|
||||
/*Settings Menu Event*/
|
||||
/*Settings Menu*/
|
||||
(i => i.onclick = e => { onbeforeunload = e => { if (i.checked) return e.returnValue = 'Error Tab Cloak' } })($('csel'));
|
||||
|
||||
/*Fullscreen Feature Addition*/
|
||||
/*Unimplemented Fullscreen*/
|
||||
//$('fullscreen').onclick=e=>e.preventDefault()||$('theframe').requestFullscreen()
|
||||
}, 0);
|
||||
|
||||
/*Title and Icon Cookies*/
|
||||
setPreferences = (e, i, a) => { e = 'HBTitle', i = 'HBIcon', a = [] + void[], readCookie(e) == a || pageTitle(readCookie(e));
|
||||
readCookie(i) == a || pageIcon(readCookie(i)) };
|
||||
|
||||
/*Set Secure Cookie*/
|
||||
/*Cookie Storage*/
|
||||
(d => { d.setMonth(d.getMonth() + 12);
|
||||
setCookie = (n, v) => { document.cookie = n + `=${encodeURIComponent(v)};expires=${d.toUTCString()};SameSite=None;Secure` } })(new Date());
|
||||
setCookie = (n, v) => { document.cookie = n + `=${([]+v).replace(/.|\n/g,p=>{try{return/[\w\d-.!~*'()]/.test(p)?'%'+p.charCodeAt().toString(16).toUpperCase():encodeURIComponent(p)}catch{return p}})};expires=${d.toUTCString()};SameSite=None;Secure` } })(new Date());
|
||||
|
||||
/*Read Cookie*/
|
||||
readCookie = n => { try { return decodeURIComponent(document.cookie.split('; ').filter(e => e.startsWith(n + '='))[0].slice(n.length + 1)) } catch { return [] } };
|
||||
readCookie = n => ([] + document.cookie.split('; ').filter(e => e.startsWith(n + '='))[0]).slice(([] + n).length + 1).replace(/(%[A-z\d]{2})+/g, decodeURIComponent);
|
||||
|
||||
/*Set Title & Icon from Input Value*/
|
||||
/*Set Title & Icon*/
|
||||
pageTitle = v => { document.title = v; try { parent.document.title = v } catch (e) { console.log(e) } };
|
||||
pageIcon = (v, l, e) => { document.head.appendChild(((l = document.querySelector(e = 'link[rel*=icon]') || document.createElement('link')).rel = 'icon', l.href = v, l)); try { parent.document.head.appendChild(((l = parent.document.querySelector(e) || document.createElement('link')).rel = 'icon', l.href = v, l)) } catch (e) { console.log(e) } };
|
||||
|
||||
/*Store Title & Icon*/
|
||||
setTitle = v => pageTitle(v) || setCookie('HBTitle', v);
|
||||
setIcon = v => pageIcon(v) || setCookie('HBIcon', v);
|
||||
|
||||
/* Title & Icon Attach*/
|
||||
pageTitle = v => { document.title = v; try { parent.document.title = v } catch (e) { console.log(e) } };
|
||||
pageIcon = (v, l, e) => { e = 'link[rel*=icon]', document.head.appendChild(((l = document.querySelector(e) || document.createElement('link')).rel = 'icon', l.href = v, l)); try { parent.document.head.appendChild(((l = parent.document.querySelector(e) || document.createElement('link')).rel = 'icon', l.href = v, l)) } catch (e) { console.log(e) } };
|
||||
/*Set Stored Title & Icon*/
|
||||
setPreferences = (e, i, a) => { readCookie(e = 'HBTitle') == (a = [] + void[]) || pageTitle(readCookie(e));
|
||||
readCookie(i = 'HBIcon') == a || pageIcon(readCookie(i)) };
|
||||
|
||||
/* Tab Cloak*/
|
||||
/*Sift Tabs*/
|
||||
autoChange = (e, r) => { $('csel').checked ? pageTitle(titles[e = (r = (a, b) => Math.floor(Math.random() * (b - a + 1)) + a)(1, 5)], pageIcon(icons[e]), setTimeout(autoChange, r(1e4, 6e4))) : setPreferences() }
|
Loading…
Add table
Add a link
Reference in a new issue