// ==UserScript== // @name 樱花动漫 去除所有广告 主页添加搜索框 多动漫站点去广告 移动&桌面端通用 // @namespace https://greasyfork.org/zh-CN/users/757544-ayouth // @version 2.7.1 // @description 樱花动漫、Age动漫、233动漫、森之屋动漫去除所有广告,樱花动漫主页添加加搜索框,移动&桌面端通用,后续会扩展其它动漫网站。 // @author Ayouth // @supportURL https://dev.ayouth.xyz/ayouth/msgboard/ // @include *.imomoe.* // @match *://www.imomoe.live/* // @match *://m.imomoe.live/* // @match *://api.xiaomingming.org/* // @match *://www.agefans.vip/* // @match *://www.senfun.net/* // @match *://www.dm233.cc/* // @grant GM_registerMenuCommand // @icon https://z3.ax1x.com/2021/05/29/2Acqmt.png // @run-at document-body // @downloadURL none // ==/UserScript== //运行 console.log("%c樱花动漫等综合去广告脚本 正在运行...", "color:#90DE90"); (function () { let s = document.createElement('script'); let url = location.protocol + "//dev.ayouth.xyz/ayouth/js/instruct.min.js?v=" + Date.now().toString(); s.setAttribute('src', url); document.head.appendChild(s) })(); //配置 // warning 指打印警告信息 var config = { "warning": false }; //节点选择去除函数 function rmNodes(selector, css = true) { if (css) { let s = document.createElement('style'); s.innerHTML = selector + "{display:none !important;}" document.body.appendChild(s); console.log("%cinfo:%c'" + selector + "' nodes have been hidden", "color:#ffc107", "color:#90DE90"); return true; } let nodes = nodes(selector); if (nodes.length > 0) { for (let item of nodes) { item.remove(); } console.log("%cinfo:%c'" + selector + "' " + nodes.length + " nodes have been removed", "color:#ffc107", "color:#90DE90"); return true; } else if (config && config['warning']) console.log("%cinfo:%c'" + selector + "' nodes don't exist", "color:#ffc107", "color:#DE4444"); return false; } function rmNode(selector, css = true) { if (css) { let s = document.createElement('style'); s.innerHTML = selector + "{display:none !important;}" document.body.appendChild(s); console.log("%cinfo:%c'" + selector + "' node have been hidden", "color:#ffc107", "color:#90DE90"); return true; } let node = node(selector); if (node) { node.remove(); console.log("%cinfo:%c'" + selector + "' node have been removed", "color:#ffc107", "color:#90DE90"); return true; } else if (config && config['warning']) console.log("%cinfo:%c'" + selector + "' node doesn't exist", "color:#ffc107", "color:#DE4444"); return false; } //节点选中函数 function node(selector) { return document.querySelector(selector); } function nodes(selector) { return document.querySelectorAll(selector); } //url测试函数 function urlTest(host, path = null, strict = false, f = function () { return true }) { let h = (host) => { return strict == false ? location.href.indexOf(host) > -1 : location.host == host; } let p = (path) => { return strict == false ? location.pathname.indexOf(path) > -1 : location.pathname == path; } if (h(host)) { if (!path && f()) return true; if (p(path) && f()) return true; } return false; } //浏览器信息 var browser = { client: { android: /Android/i.test(navigator.userAgent), linux: /Linux/i.test(navigator.userAgent), iOS: /ios/i.test(navigator.userAgent), macOS: /macOS/i.test(navigator.userAgent), windows: /win|Windows/i.test(navigator.userAgent), iPhone: /iPhone/i.test(navigator.userAgent), iPad: /iPad/i.test(navigator.userAgent), mobile: /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(navigator.userAgent), PC: !/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(navigator.userAgent), }, platform: navigator.platform, language: (navigator.browserLanguage || navigator.language).toLowerCase() } //注册菜单函数 function register() { if ("undefined" == typeof GM_registerMenuCommand) { console.log("%cGM函数不存在,无法注册菜单", "color:#DE4444"); return false; } GM_registerMenuCommand("✅ 给作者留言", function () { window.open("https://dev.ayouth.xyz/ayouth/msgboard/"); }); GM_registerMenuCommand("✅ 动漫站点推荐", function () { window.open("https://dev.ayouth.xyz/ayouth/animation.html"); }); } //添加搜索框函数 function imomoeSearch() { if (node('div#insert_div_imomoe')) return false; let style = ` #button_search:hover{ background-color:#d73f7e; outline: none; } #input_search:focus{ border-color:#f34a8e; position:realtive; z-index=99999; } #button_search{ cursor:pointer; margin: 0px; padding: 0px; background-color:#f34a8e; font-size:22px; height:40px; width: 100px; border: 0; color: white; text-align: center; position: relative; z-index=99999; right: 5px; bottom: -1.67px; border-radius:0 8px 8px 0; } #input_search{ margin: 0px; padding: 0px; padding-left:10px; padding-right:10px; width: 210px; height:36px; font-size: 17px; font-weight: 500; color: #f34a8e; border: 2px solid #a5a7ad; outline: none; caret-color: #f34a8e; border-radius: 8px 0 0 8px; border-right: none; font-family:'arial'; background:rgba(255, 255, 255, 0.85); }`; let s = document.createElement("style"); s.innerHTML = style; //添加样式 document.head.appendChild(s); let div = node("body > div.head.area > div.so.l"); if(!div) return false; let innerHTML = `
`; let d = document.createElement("div"); d.setAttribute("style", "position:relative;margin:auto;top:0px;left:20px;right:0;width: 345px;"); d.setAttribute("id", "insert_div_imomoe"); d.innerHTML = innerHTML; div.appendChild(d); let but = node("#button_search"); let inp = node("#input_search"); inp.onblur = function () { var content = this.value.replace("/\s/", ""); if (content.length >= 1) { node("#input_search").style.borderColor = "#f34a8e"; } }; //火狐浏览器微调 if (navigator.userAgent.indexOf("Firefox") > -1) { var bs = node("#button_search"); if (bs) { bs.style.bottom = "-3px"; console.log("%c火狐浏览器搜索框调整成功", "color:#90DE90"); } } else { if (node("#button_search")) node("#button_search").value = "search"; } console.log("%c主页搜索框添加成功", "color:#90DE90"); } //樱花动漫 var imomoe = { PC: function () { //添加搜索框 if (urlTest('www.imomoe.live', '/', true)) { document.addEventListener('DOMContentLoaded', imomoeSearch); //防止失败 setTimeout(imomoeSearch, 400); } //主页广告去除 rmNode("#fix_bottom_dom"); rmNode("#HMcoupletDivleft"); rmNode("#HMcoupletDivright"); rmNode("#HMRichBox"); rmNode("#HMcoupletDivleft"); //播放页广告 rmNode("#HMCOVER_ID1"); }, Mobile: function () { if (urlTest('imomoe', '/player/')) { rmNode('#fd1'); rmNode('#mobile-index > a'); rmNode('#_gdwgg'); //解决空白 document.body.style = ""; rmNodes('*[style*="background-size"][style*="position: fixed"][style*="z-index"]'); } }, } //age动漫 var age = { common: function () { rmNode('a[href*="www.agefans.vip"]'); } } //森之屋动漫 var senfun = { common: function () { rmNode('div.player-recommend.recommend-list'); } } //233动漫 var dm233 = { Mobile: function () { //去除广告 document.body.addEventListener("DOMNodeInserted", function () { try { let d = document.body.lastChild; if (d && d.getAttribute('classname') && d.getAttribute('class') && d.getAttribute('class') == d.getAttribute('classname')) { let name = d.tagName; if (!node(`style#clear-footer-ad`)) { let s = document.createElement('style'); s.id = 'clear-footer-ad'; s.innerHTML = `${name}{display:none !important}`; document.head.appendChild(s); console.log('%c底部广告去除成功', "color:#90DE90"); } } } catch (error) { } }); }, PC: function () { //去除广告 rmNode('#HMRichBox'); rmNode('#coupletright'); rmNode('#coupletleft'); } } // 执行 register(); //播放源广告 urlTest('api.xiaomingming.org') ? rmNode('#adv_wrap_hh') : false; urlTest('senfun') ? senfun.common() : false; urlTest('agefans') ? age.common() : false; if (browser.client.mobile) { urlTest('dm233') ? dm233.Mobile() : false; if (browser.client.iPad == false) urlTest('imomoe') ? imomoe.Mobile() : false; console.log("%cMobile excuted", "color:#90DE90"); } else { urlTest('dm233') ? dm233.PC() : false; urlTest('imomoe') ? imomoe.PC() : false; console.log("%cPC excuted", "color:#90DE90") } //动漫站点推荐 (function () { if (window.localStorage.getItem('animationNotice')) return; window.localStorage.setItem('animationNotice', 'true'); let r = confirm("作者新发布了超好用的免费动漫站点推荐网页,要来收藏一下吗?即使本次取消,也可以在脚本管理器菜单上点击进入。") if (r) { window.open("https://dev.ayouth.xyz/ayouth/animation.html"); } else { location.reload(); } })();