Skip to content

Instantly share code, notes, and snippets.

@zorbash
Last active December 10, 2015 17:48
Show Gist options
  • Save zorbash/4470442 to your computer and use it in GitHub Desktop.
Save zorbash/4470442 to your computer and use it in GitHub Desktop.
my current default.js
(function() {
window.dotjs = {
// add websites you think are crap.
bad: [
/newsbomb.gr/,
/zougla.gr/,
/newsbeast.gr/
],
// replace them with "good" ones.
good: [
'http://butdoesitfloat.com',
'http://ubu.com',
'http://cargocollective.com/',
'http://fastcodesign.com/',
'http://fffff.at/'
],
helpers: {
replaceBadWithGood: function replaceBadWithGood() {
var
links,
current_link,
link_count,
i = 0,
j,
bad_count = dotjs.bad.length,
good_length = dotjs.good.length,
replace = function() {
var el = $(this);
el.attr('href', dotjs.good[Math.floor(Math.random() * good_length)]);
el.removeAttr('onmouseover');
el.removeAttr('data-ft');
};
$('.shareMediaLink, .shareText').attr('onmouseover', '')
.attr('onclick', '');
links = document.getElementsByTagName('a');
link_count = links.length;
//console.log('links: ' + links.length);
for (i; i < link_count; i++) {
current_link = links[i];
for (j = 0; j < bad_count; j++) {
if (current_link.href.match(dotjs.bad[j])) {
current_link.href = dotjs.good[Math.floor(Math.random() * good_length)];
current_link.onmouseover = "";
}
}
}
}
}
};
})();
$(function() {
window.dotjs.helpers.replaceBadWithGood();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment