console.log('Loading "Skip Promoted Posts" script'); //Determine if post is promoted document.addEventListener ("DOMContentLoaded", DOM_ContentReady); window.addEventListener ("load", pageFullyLoaded);
function DOM_ContentReady () { // 2ND PART OF SCRIPT RUN GOES HERE. // This is the equivalent of @run-at document-end console.log ("==> DOM_ContentReady run.", new Date() ); }
function pageFullyLoaded () { if (document.getElementsByClassName("promoted-label promoted-hover").length > 0) { console.log('Promoted post detected'); // Press the next button let nextButton = document.querySelector('.Navigation.Navigation-next');
// Check if the element exists and has an href attribute if (nextButton && nextButton.href) { // console.log('found href: ' + nextButton.href) window.location.href = nextButton.href; // Redirect to the link } } else { // console.log("not a promoted post"); } }
Doesn't work due to imgur updates. This does:
// ==UserScript==
// @name Skip Promoted Posts Script
// @namespace http://heyisthisusernametaken.com/skip_promoted
// @version 0.2
// @description Detects promoted posts and presses the next button
// @author heyisthisusernametaken
// @match https://imgur.com/*
// @require http://code.jquery.com/jquery-latest.js
// @grant click
// @run-at document-start
// ==/UserScript==
console.log('Loading "Skip Promoted Posts" script');
//Determine if post is promoted
document.addEventListener ("DOMContentLoaded", DOM_ContentReady);
window.addEventListener ("load", pageFullyLoaded);
function DOM_ContentReady () {
// 2ND PART OF SCRIPT RUN GOES HERE.
// This is the equivalent of @run-at document-end
console.log ("==> DOM_ContentReady run.", new Date() );
}
function pageFullyLoaded () {
if (document.getElementsByClassName("promoted-label promoted-hover").length > 0) {
console.log('Promoted post detected');
// Press the next button
let nextButton = document.querySelector('.Navigation.Navigation-next');
// Check if the element exists and has an href attribute
if (nextButton && nextButton.href) {
// console.log('found href: ' + nextButton.href)
window.location.href = nextButton.href; // Redirect to the link
}
} else {
// console.log("not a promoted post");
}
}