上班无事时浏览新闻,但是广告太多,就写了个小脚本,喜欢的可以拿去,嘻嘻嘻
`// UserScript
// @name 今日头条去广告
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 去除今日头条中广告信息
// @author nana
// @match http*😕/.toutiao.com/
// @require https://code.jquery.com/jquery-latest.js
// @grant none
// /UserScript
(function() {
‘use strict’;
var localHost = location.host; //当前路径
var localAddress = “”; //当前所在网站
if (localHost.indexOf(“toutiao.com”) > -1) {
localAddress = “toutiao”;
}
if (“toutiao” === localAddress) {
// Class集合
var className = [“index-right”, “bd-bottom-1”, “outer”, “right-iframe-img”,“right-img”];
removeClassName(className);
setTimeout(removeClassName(className),2000)
}
// 通过Class删除
function removeClassName(className) {
for (var i = 0; i < className.length; i++) {
var classDom = document.getElementsByClassName(className[i]);
for (var j = 0; j < classDom.length; j++) {
classDom[j].remove();
}
}
}
})();`