Why an ad blocker and other privacy tools for your browser are essential
I did it in 46 lines, and isn't perfect, but the idea behind it is scary. With the javascript code below, after any webpage with this right above the </body>
tag, I can track anyone on the website's clicks.
document.body.setAttribute("onmousedown", "whichElement(event)");
function whichElement(e) {
var targ;
if (!e) {
var e = window.event;
}
if (e.target) {
targ=e.target;
} else if (e.srcElement) {
targ=e.srcElement;
}
var tname;
tname = targ.tagName;
var aan;
aan = tname.toLowerCase().substring(0, 1);
var vowels = ['a','e','i','o','u'];
if(vowels.includes(aan)){aan = 'an';} else {aan = 'a';}
var tvalue;
if(tname==="IMG"){
tvalue = targ.src;
console.log('You clicked on ' + aan + ' ' + tname + ' element: "' + tvalue + '".');
sendTrackInfo('UserClick', tname, tvalue);
} else if(tname!=="INPUT"&&tname!=="DIV"){
tvalue = targ.innerText;
if(!tvalue){tvalue = targ.title;}
if(!tvalue){tvalue = "Unknown";}
console.log('You clicked on ' + aan + ' ' + tname + ' element: "' + tvalue + '".');
sendTrackInfo('UserClick', tname, tvalue);
} else {
console.log("You clicked on " + aan + " " + tname + " element.");
sendTrackInfo('UserClick', tname, 'Login Form');
}
}
function sendTrackInfo(action, name, value){
if(action&&name&&value){
_paq.push(['trackEvent', action, name, value]);
}
}
function sendUserInfo(){
var username = "Unknown";
if(document.getElementById("username") !== "undefined"){username = document.getElementById("username").textContent;}
if(ncuser != "Unknown"){
_paq.push(["setCustomVariable", 1, "User", username, "visit"]);
console.log('"'+ncuser+'"');
}
}
Necessary tools
- uBlock Origin - "NOT an 'ad blocker': it is a wide-spectrum blocker -- which happens to be able to function as a mere 'ad blocker'. The default behavior of uBlock Origin when newly installed is to block ads, trackers and malware sites -- through EasyList, EasyPrivacy, Peter Lowe’s ad/tracking/malware servers, various lists of malware sites, and uBlock Origin's own filter lists."
- HTTPS Everywhere - "a Firefox, Chrome, and Opera extension that encrypts your communications with many major websites, making your browsing more secure."
- Privacy Badger - "automatically learns to block invisible trackers."
Optional tools
- NoScript - turn off javascript completely or only allow the most trusted javascript sources.
#matomo #google #amazon #analytics #javascript #web #website #webdesign #adblock #ublock #ublockorigin #eff #privacy #privacybadger #extension #extensions