Skip to content

Commit

Permalink
Apply nowgg fix when in about:blank (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
xbubbo committed Mar 28, 2024
1 parent 17acb1f commit c6210d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
35 changes: 14 additions & 21 deletions static/assets/scripts/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function decodeXor(input) {
.join('') + (search.length ? '?' + search.join('?') : '')
)
}

function iframeLoad() {
if (document.readyState === 'complete') {
const website = iframe.contentWindow?.location.href.replace(window.location.origin, '')
Expand All @@ -20,12 +21,10 @@ function iframeLoad() {
const website = iframe.contentWindow?.location.href.replace(window.location.origin, '').replace('/a/', '')
document.getElementById('is').value = decodeXor(website)
localStorage.setItem('decoded', decodeXor(website));
window.parent.postMessage({ decodedSet: true }, window.location.origin);
} else if (website.includes('/a/q/')) {
const website = iframe.contentWindow?.location.href.replace(window.location.origin, '').replace('/a/q/', '')
document.getElementById('is').value = decodeXor(website)
localStorage.setItem('decoded', decodeXor(website));
window.parent.postMessage({ decodedSet: true }, window.location.origin);
}
}
}
Expand Down Expand Up @@ -140,24 +139,21 @@ document.addEventListener('fullscreenchange', function () {
document.body.classList.toggle('fullscreen', isFullscreen)
})
// Now
const key = ['nowgg', 'now.gg'];
const decoded = localStorage.getItem('decoded');
let decodedSet = false;
const decoded = localStorage.getItem('decoded');
const key = ['nowgg', 'now.gg'];

window.addEventListener('message', function(event) {
if (event.origin !== window.location.origin) {
console.warn('Received message from unexpected origin:', event.origin);
return;
}

if (event.data && event.data.decodedSet === true) {
decodedSet = true;
console.log('Starting process.');
now();
}
});
if (localStorage.getItem('decoded') !== null) {
decodedSet = true;
console.log('Starting process.');
now();
} else {
decodedSet = false;
console.log('Decoded not found.');
}

function now() {
console.log('Executing now() function.');
if (decoded) {
let found = false;
for (const keyword of key) {
Expand All @@ -171,12 +167,13 @@ function now() {
let count = 0;
let notfound = 0;
const limit = 10;
const max = 35;
const max = 45;
const reloadInterval = setInterval(() => {
if (count < limit && iframe) {
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
const element = iframeDocument.querySelector('.sc-hGPBjI.gGkQpt');
if (element) {
console.log("Class found inside the iframe.");
document.querySelector('.overlay').style.display = 'block';
document.getElementById('ifra').style.display = 'none';
iframeDocument.location.reload();
Expand All @@ -200,7 +197,3 @@ function now() {
console.log('Decoded not found in localStorage.');
}
}

if (decodedSet) {
now();
}
2 changes: 1 addition & 1 deletion static/go.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h1>Now.gg fix is being applied, please wait.</h1>
width="100%"
allowfullscreen></iframe>
<script src="assets/scripts/index.js?v=9"></script>
<script src="assets/scripts/frame.js?v=26"></script>
<script src="assets/scripts/frame.js?v=28"></script>
<script src="/assets/scripts/main.js?v=18"></script>
<script src="./m/bundle.js?v=5"></script>
<script src="./m/config.js?v=5"></script>
Expand Down

0 comments on commit c6210d0

Please sign in to comment.