@@ -39,6 +39,18 @@ document.addEventListener("DOMContentLoaded", function (event) {
3939 newIframe . dataset . tabId = tabCounter
4040 newIframe . classList . add ( "active" )
4141
42+ newIframe . addEventListener ( "load" , ( ) => {
43+ const title = newIframe . contentDocument . title
44+ if ( title . length <= 1 ) {
45+ tabTitle . textContent = "New Tab"
46+ } else {
47+ tabTitle . textContent = title
48+ }
49+ if ( newIframe . contentDocument . documentElement . outerHTML . trim ( ) . length > 0 ) {
50+ Load ( )
51+ }
52+ } )
53+
4254 const GoURL = sessionStorage . getItem ( "GoUrl" )
4355
4456 if ( tabCounter === 1 ) {
@@ -54,52 +66,6 @@ document.addEventListener("DOMContentLoaded", function (event) {
5466 }
5567
5668 iframeContainer . appendChild ( newIframe )
57- // Decode URL
58- function decodeXor ( input ) {
59- if ( ! input ) return input
60- let [ str , ...search ] = input . split ( "?" )
61-
62- return (
63- decodeURIComponent ( str )
64- . split ( "" )
65- . map ( ( char , ind ) => ( ind % 2 ? String . fromCharCode ( char . charCodeAt ( NaN ) ^ 2 ) : char ) )
66- . join ( "" ) + ( search . length ? "?" + search . join ( "?" ) : "" )
67- )
68- }
69-
70- function Load ( ) {
71- const activeIframe = document . querySelector ( "#iframe-container iframe.active" )
72- if ( activeIframe && activeIframe . contentWindow . document . readyState === "complete" ) {
73- const website = activeIframe . contentWindow . document . location . href
74- if ( website . includes ( "/a/" ) ) {
75- const websitePath = website . replace ( window . location . origin , "" ) . replace ( "/a/" , "" )
76- const decodedValue = decodeXor ( websitePath )
77- document . getElementById ( "is" ) . value = decodedValue
78- } else if ( website . includes ( "/a/q/" ) ) {
79- const websitePath = website . replace ( window . location . origin , "" ) . replace ( "/a/q/" , "" )
80- const decodedValue = decodeXor ( websitePath )
81- document . getElementById ( "is" ) . value = decodedValue
82- } else {
83- const websitePath = website . replace ( window . location . origin , "" )
84- document . getElementById ( "is" ) . value = websitePath
85- }
86- }
87- }
88-
89- newIframe . addEventListener ( "load" , ( ) => {
90- console . log ( "Iframe loaded" )
91- const title = newIframe . contentDocument . title
92- if ( title . length <= 1 ) {
93- console . log ( "Title is too short, setting tabTitle to 'New Tab'" )
94- tabTitle . textContent = "New Tab"
95- } else {
96- console . log ( "Title is:" , title )
97- tabTitle . textContent = title
98- }
99- if ( newIframe . contentDocument . documentElement . outerHTML . trim ( ) . length > 0 ) {
100- Load ( )
101- }
102- } )
10369
10470 tabCounter ++
10571 }
@@ -339,8 +305,6 @@ document.addEventListener("DOMContentLoaded", function () {
339305
340306 console . log ( navIcon )
341307 navIcon . addEventListener ( "click" , function ( ) {
342- console . log ( "Nav icon clicked" )
343-
344308 var isOpen = navBar . classList . toggle ( "hidden" )
345309 this . classList . toggle ( "open" )
346310 if ( isOpen ) {
@@ -356,3 +320,37 @@ if (navigator.userAgent.includes("Chrome")) {
356320 navigator . keyboard . lock ( [ "Escape" ] )
357321 } )
358322}
323+
324+ function Load ( ) {
325+ const activeIframe = document . querySelector ( "#iframe-container iframe.active" )
326+ if ( activeIframe && activeIframe . contentWindow . document . readyState === "complete" ) {
327+ const website = activeIframe . contentWindow . document . location . href
328+ if ( website . includes ( "/a/" ) ) {
329+ const websitePath = website . replace ( window . location . origin , "" ) . replace ( "/a/" , "" )
330+ localStorage . setItem ( "decoded" , websitePath )
331+ const decodedValue = decodeXor ( websitePath )
332+ document . getElementById ( "is" ) . value = decodedValue
333+ } else if ( website . includes ( "/a/q/" ) ) {
334+ const websitePath = website . replace ( window . location . origin , "" ) . replace ( "/a/q/" , "" )
335+ const decodedValue = decodeXor ( websitePath )
336+ localStorage . setItem ( "decoded" , websitePath )
337+ document . getElementById ( "is" ) . value = decodedValue
338+ } else {
339+ const websitePath = website . replace ( window . location . origin , "" )
340+ document . getElementById ( "is" ) . value = websitePath
341+ localStorage . setItem ( "decoded" , websitePath )
342+ }
343+ }
344+ }
345+
346+ function decodeXor ( input ) {
347+ if ( ! input ) return input
348+ let [ str , ...search ] = input . split ( "?" )
349+
350+ return (
351+ decodeURIComponent ( str )
352+ . split ( "" )
353+ . map ( ( char , ind ) => ( ind % 2 ? String . fromCharCode ( char . charCodeAt ( NaN ) ^ 2 ) : char ) )
354+ . join ( "" ) + ( search . length ? "?" + search . join ( "?" ) : "" )
355+ )
356+ }
0 commit comments