Skip to content

Instantly share code, notes, and snippets.

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 neoOpus/2aa8f33b417a55d980191efc9b20582b to your computer and use it in GitHub Desktop.
Save neoOpus/2aa8f33b417a55d980191efc9b20582b to your computer and use it in GitHub Desktop.
UserScript - Remove Reddit Promoted Post
// ==UserScript==
// @name Reddit Hide Promoted Links (New Design)
// @namespace http://github.com/rohenaz
// @version 0.1
// @description remove promoted posts and advertisements
// @author Satchmo
// @match https://www.reddit.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let els = document.getElementsByClassName('promotedlink')
clean(els)
setInterval(() => {
let adEls = document.querySelectorAll('[data-google-query-id]')
clean(adEls)
}, 2000)
})();
function clean(els) {
if(els) {
let x = els.length
while(x--) {
if (els[x].getAttribute('data-slot')) {
els[x] = els[x].parentElement.parentElement.parentElement
}
els[x].style.display = 'none'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment