Open dzihan-a opened 4 months ago
See FAQ19, you can write your own custom change detector. Also you can send toggle-requested
event if you don't need the extension to continue reloading.
Thank you for your reply,
I tried the code
{ async function sha256(message) { const script = document.currentScript; const msgBuffer = new TextEncoder('utf-8').encode(message); const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer); const hashArray = Array.from(new Uint8Array(hashBuffer)); const hashHex = hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join(''); return hashHex; } sha256(document.body.innerText).then(hash => { const key = 'tab-reloader-hash-' + location.href; const oh = localStorage.getItem(key); if (oh && oh !== hash) { script.dispatchEvent(new Event('toggle-requested')); } localStorage.setItem(key, hash); }); }
which however did not work for me. Probably simply a bug in the code I did which I do not see...
open the developer console of the browser (right-click on page and use inspect item, then switch to the console tab) and run the code inside it. When it is fixed, then run it with tab reloader.
Well, I still would appreciate it a lot if a new version would bring a simple checkbox in the options to implement this feature. Nevertheless, here is the working code for anyone who is interested:
{ const script = document.currentScript;
async function sha256(message) { const msgBuffer = new TextEncoder('utf-8').encode(message); const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer); const hashArray = Array.from(new Uint8Array(hashBuffer)); const hashHex = hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join(''); return hashHex; } sha256(document.body.innerText).then(hash => { const oh = localStorage.getItem('tab-reloader-hash'); if (oh && oh !== hash) { window.setTimeout(() => { script.dispatchEvent(new Event('toggle-requested')); }, 500); } localStorage.setItem('tab-reloader-hash', hash); }); }
Tab-Reloader will detect changes in a webpage and play a sound, however it will continue to reload forever. What javascript code is necessary to stop the reloader after a change has been detected?
Could this function be implemented in an upgrade with a checkbox?