Created
October 28, 2021 04:37
-
-
Save jonalter/f633f1a3305f94770ecbf120889999a0 to your computer and use it in GitHub Desktop.
Removes ads from colonist.io - Use with Tampermonkey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Remove Ads | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Removes ads from colonist.io | |
// @author jonalter | |
// @match https://colonist.io/ | |
// @icon https://www.google.com/s2/favicons?domain=colonist.io | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var classNamesToDelete = [ | |
'lobby_ad_left', | |
'lobby_ad_right', | |
'in-game-ad-left', | |
'in-game-ad-right', | |
'endgame-google-ad-left', | |
'endgame-google-ad-right', | |
'in-game-ad-bottom-small' | |
]; | |
function deleteElementsWithClass(className) { | |
console.log("Searching for elements to delete for class: " + className); | |
var elementsFound = document.getElementsByClassName(className); | |
Array.from(elementsFound).forEach(function(element){ | |
console.log("Removing element: " + element); | |
element.remove(); | |
}); | |
} | |
function deleteElementsWithId(id) { | |
console.log("Searching for elements to delete for id: " + id); | |
var element = document.getElementById(id); | |
if (element) { | |
console.log("Removing element: " + element); | |
element.remove(); | |
} | |
} | |
console.log("Testing for ads"); | |
classNamesToDelete.forEach(deleteElementsWithClass); | |
classNamesToDelete.forEach(deleteElementsWithId); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment