Click here to Skip to main content
15,120,078 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I recently found out what a bookmarklet was and I was instantly interested. I was wondering if there was a way to make one that alerts when the website changes (When I get a message in https://chat-app-a2a87.web.app/ or when I get an email on https://mail.google.com/). I can't use notifications.
Is it possible, and if so how? Also, is changing the favicon possible instead of an alert?

What I have tried:

JavaScript
javascript:(function(){ var xmlHttp = getXMLHttpObj(); if(xmlHttp == null){ alert('Failed to load XMLHTTP'); return; } var actual = getPageContent(xmlHttp, window.location.href); var intervalId = window.setInterval(function(){ var current = getPageContent(xmlHttp, window.location.href); if(actual != current){ alert('This page has been modified since you opened it'); window.clearInterval(intervalId); } }, 1000); function getPageContent(xmlHttp, url){ xmlHttp.open('GET', window.location.href, false); xmlHttp.send(''); return xmlHttp.responseText; } function getXMLHttpObj(){ if(typeof(XMLHttpRequest)!='undefined') return new XMLHttpRequest(); var axO=['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP']; for(var i = 0; i < axO.length; i++){ try{ return new ActiveXObject(axO[i]); }catch(e){} } return null; }})()
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900