// ==UserScript== // @name 网易邮箱网页版去广告 // @namespace https://greasyfork.org/ // @version 0.0.1 // @description 自动关闭网页版网易邮箱'网易严选'和'半个电台'tab页,关闭主页的广告,去除'vip'和'官方APP' // @author AlinQaQ // @match *://*.mail.163.com/js6/main.jsp* // @icon https://mail.163.com/favicon.ico // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; /** * 点击自动关闭广告 * 不再使用这种方式 */ function clickToClose (textList_click){ if(textList_click!==undefined){ for(var text of textList_click){ //获取需要去除的广告元素 var clickEle=document.querySelector("li[title='"+text+"']>a"); if(clickEle!==null){ //执行点击事件关闭 clickEle.click(); } } } } /** * 删除元素关闭广告 */ function removeToClose (removeList){ if(removeList!==undefined){ for(var ele of removeList){ //获取需要去除的广告元素 var removeEle=document.querySelector('#'+ele); if(removeEle!=null){ //获取父节点 var parent = removeEle.parentElement; // 删除: parent.removeChild(removeEle); } } } } /** * 不好使的方式,先留个坑位 */ function delayDel(classNameList){ if(classNameList!==undefined){ for(var className of classNameList){ if(className!=null){ var inst=setTimeout( (function(){ //console.log("hhhh==="+className); var removeEle=document.querySelector('.'+className); //if(removeEle ==null){ // removeEle=document.querySelector('#'+className); // } if(removeEle!==null){ //获取父节点 var parent = removeEle.parentElement; // 删除: parent.removeChild(removeEle); console.log("删除"); } })(className),1000); } } } } //var textList_click=['网易严选','半个电台']; //clickToClose(textList_click); var removeList = ['_mail_component_103_103','_mail_component_108_108','_mail_component_230_230','_mail_tabitem_3_120','_mail_tabitem_2_115']; removeToClose(removeList); //var classNameList = ['gWel-bottom']; //delayDel(classNameList); /** * 删除主页广告,使用定时器延迟删除 */ var inst=setTimeout( function(){ var removeEle=document.querySelector('.gWel-bottom'); if(removeEle!==null){ //获取父节点 var parent = removeEle.parentElement; // 删除: parent.removeChild(removeEle); } //console.log("删除"); },1000); })();