Hide links with rel="noopener nofollow sponsored"
当前为
// ==UserScript==
// @name Hide Promotion Advertisement at Reddit Site
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Hide links with rel="noopener nofollow sponsored"
// @author aspen138
// @match *://*.reddit.com/
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// Function to hide elements with a specific rel attribute value
function hideElementsWithRel() {
// Select all <a> elements on the page
const links = document.querySelectorAll('a');
// Iterate through all links
links.forEach(link => {
// Check if the rel attribute matches "noopener nofollow sponsored"
if (link.getAttribute('rel') === "noopener nofollow sponsored") {
// Hide the element
link.style.display = 'none';
}
});
}
// Run the function on page load
hideElementsWithRel();
// Optional: If the page dynamically loads content, you may need to run the function again.
// This can be achieved by setting an interval or using MutationObserver for a more advanced solution.
})();