Skip to content

Instantly share code, notes, and snippets.

@CosbyArt
Created March 13, 2018 12:50
Show Gist options
  • Save CosbyArt/cb3c58d1cc9575c6045affef4272163f to your computer and use it in GitHub Desktop.
Save CosbyArt/cb3c58d1cc9575c6045affef4272163f to your computer and use it in GitHub Desktop.
Simple Greasemonkey script for GoComics.com site to fix image links and remove most ads
// ==UserScript==
// @name GoComics-3-2018
// @version 1.0
// @grant none
// @include http://*.gocomics.com/*
// ==/UserScript==
//
//Simple Greasemonkey script for GoComics.com site to fix image links and remove most ads
//CosbyArt 3-13-2018
//Find cartoon image link
var comiclink = "";
var elems = document.getElementsByTagName('*'), i;
for (i in elems) {
if((' ' + elems[i].className + ' ').indexOf(' ' + 'js-item-comic-link' + ' ') > -1) {
for (var h=i;h<elems.length;h++) {
if(elems[h].getAttribute('src')) {
comiclink = elems[h].getAttribute('src');
break;
}
}
}
}
//Fix cartoon image link
if(comiclink) {
var anchors = document.querySelectorAll('a.item-comic-link-disabled');
for(var i=0;i<anchors.length;i++){
anchors[i].href = comiclink;
}
var elements = document.getElementsByClassName('item-comic-link-disabled');
for (var i in elements) {
if (elements.hasOwnProperty(i)) {
elements[i].className = 'js-item-comic-link';
}
}
}
//Simple ad blocking
var anchors = document.querySelectorAll('div.amu-container-ad-wrapper');
for(var i=0;i<anchors.length;i++){
anchors[i].innerHTML = "";
}
var anchors = document.getElementById('recommendations_holder');
anchors.remove();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment