Created
July 19, 2024 07:41
-
-
Save ricky9w/4e84b08780f4e5bbed217b20167fc1a3 to your computer and use it in GitHub Desktop.
Remove Sohu pop-ups and slide-bar ads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Souhu Hide Distractions | |
// @version 0.1 | |
// @description Remove Sohu pop-ups and slide-bar ads | |
// @author ricky9w | |
// @email [email protected] | |
// @match https://www.sohu.com/a/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// 要删除的元素选择器 | |
const elementsToRemove = [ | |
'div#right-side-bar', | |
'div#left-bottom-god', | |
'div.left-bottom-float-fullScreenSleep' | |
]; | |
// 删除元素 | |
function removeElements() { | |
elementsToRemove.forEach(selector => { | |
const element = document.querySelector(selector); | |
if (element) { | |
element.remove(); | |
} | |
}); | |
} | |
// 在页面加载完成后执行隐藏操作 | |
if (document.readyState === 'loading') { | |
document.addEventListener('DOMContentLoaded', removeElements); | |
} else { | |
removeElements(); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment