Removes promoted answers that have nothing to do with the question you're looking up
当前为
// ==UserScript==
// @name Remove promoted questions and answers on Quora
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Removes promoted answers that have nothing to do with the question you're looking up
// @author A long-time Quora user annoyed by the irrelevant ads that pollute the site
// @match https://www.quora.com/*
// @match https://quora.com/*
// @icon https://www.google.com/s2/favicons?domain=quora.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
var logRemovalsToDevConsole = false; // Change this to true to log removals to the console
setInterval(function() {
// search for the "Promoted by" string
var xpathResult = document.evaluate("//div[contains(@class, 'qu-fontSize--small') and contains(., 'Promoted by')]", document, null, XPathResult.ANY_TYPE, null);
if (xpathResult) {
var textBlock = null;
while ((textBlock = xpathResult.iterateNext()) !== null) {
var node = textBlock;
do {
node = node.parentNode;
} while (node && node.className.indexOf('CssComponent') == -1); // find the parent node with a CssComponent class, this is the block we want to remove
if (node && node.parentNode) {
logRemovalsToDevConsole && console.log('Removing promoted block', node);
node.parentNode.removeChild(node);
}
}
}
}, 200); // repeat as more results are loaded (every 200ms)
})();