Skip to content

Instantly share code, notes, and snippets.

@enlavin
Created June 18, 2020 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enlavin/3849253cac5f3a852e35c39e9a7edf13 to your computer and use it in GitHub Desktop.
Save enlavin/3849253cac5f3a852e35c39e9a7edf13 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name dotmain
// @namespace http://enlavin.com/
// @version 0.1
// @description Adds a dot at the end of the url domains to mess up with ads
// @author enlavin
// @match http*://*/*
// ==/UserScript==
(function() {
'use strict';
function dotit(url) {
var u = new URL(url, location.href);
if (u.hostname != '' && u.hostname[u.length - 1] != '.') {
u.hostname += '.';
}
return u.toString();
}
//if (location.href[location.href.length - 1] != '.') {
// location.href = dotit(location.href);
//}
var links = document.getElementsByTagName('a');
for (var idx in links) {
var a = links[idx];
try {
a.href = dotit(a.href);
} catch (e) {
continue;
}
console.log(a.hostname);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment