highlight Sponsored content from google search results in light red
当前为
// ==UserScript==
// @name google_search_results_categorize
// @namespace http://tampermonkey.net/
// @version 0.1
// @description highlight Sponsored content from google search results in light red
// @author Manyu Lakhotia
// @match https://www.google.com/search?*
// @icon s
// @grant none
// @license MIT
// ==/UserScript==
(function () {
'use strict';
function main() {
const domEles = Array.from(document.querySelectorAll('div')).filter(div => {
return div.querySelector(':scope span')?.textContent.trim() === 'Sponsored';
});
domEles.forEach(domEle => {
domEle.style.backgroundColor = 'rgba(255, 170, 170, 0.1)';
});
}
const targetNode = document.getElementsByTagName('html')[0];
const observerConfig = {attributes: true, childList: true};
const observer = new MutationObserver(main);
observer.observe(targetNode, observerConfig);
})();