remove ads

clear site ui

  1. // ==UserScript==
  2. // @name remove ads
  3. // @namespace websiteEnhancement
  4. // @version 2024.9.5
  5. // @description clear site ui
  6. // @author jim
  7. // @include /http[s]?\:\/\/([a-z\.]*\.)?[myjavbay|eporner|footfan|sis001|theporn|av6k|eqpp|bdsmx|vjav|soav|pornlulu|arival|avtb].*\..*/
  8. // @exclude *://*.doubleclick.*/*
  9. // @exclude *://*advertising*
  10. // @exclude *://*banner*
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @grant GM.getValue
  14. // @grant GM.setValue
  15. // @require https://openuserjs.org/src/libs/sizzle/GM_config.min.js
  16. // @license MIT
  17. // @run-at document-start
  18. // ==/UserScript==
  19.  
  20. ; (async function (withjQuery, addStyle, createSuperLabel) {
  21. "use strict";
  22.  
  23. if (window.self !== window.top) {
  24. return;
  25. } // end execution if in a frame
  26. let conf = new GM_config({
  27. id: 'GM_config_removeAds',
  28. title: 'Configurable Options Script',
  29. fields: {
  30. 'conf': {
  31. 'label': 'Search keys',
  32. 'type': 'textarea',
  33. rows: 20,
  34. cols: 50,
  35. 'default': `
  36. [
  37. {
  38. "matches": [
  39. "avtb"
  40. ],
  41. "selectors": [
  42. ".ads"
  43. ]
  44. },
  45. {
  46. "matches": ["wkgo"],
  47. "selectors": [
  48. "[id*=stickthread],.quote img,#f_pst,#ft",".bm.bml.pbn",".t_f br,.t_f .jammer",".ad",".pl > :nth-child(n+4)",".pl span:hidden","[id*=normalthread]:contains(AI)","[id*=normalthread]:contains(ai)","[id*=normalthread]:contains(馬賽克)","[id*=normalthread]:contains(AI)","[id*=normalthread]:contains(去码)","[id*=normalthread]:contains(马克赛)","[id*=normalthread]:contains(马赛克)"
  49. ]
  50. },
  51. {
  52. "matches": ["sexinsex"],
  53. "selectors": [
  54. "div:has(h1:contains('请关闭广告屏蔽插件以支持我们的网站'))"
  55. ]
  56. },
  57. {
  58. "matches": ["javdb"],
  59. "selectors": [
  60. ".top-meta",".video-detail>:nth-child(n+5)"
  61. ]
  62. }
  63. ]`
  64. },
  65. },
  66. });
  67. withjQuery(function ($, window) {
  68.  
  69. let w = 40, h = 40;
  70. addStyle(`
  71. .btn1 {
  72. opacity:0.8;-moz-transition-duration:0.2s;-webkit-transition-duration:0.2s;
  73. padding:1px; margin-top:1px;
  74. font-size: 10; text-align: center; vertical-align: middle; line-height:${h}px;
  75. border-radius:5px 5px 5px 5px;cursor:pointer; left:0px;z-index:9999;
  76. background: white;
  77. width:${w}px;height:${h}px;
  78. }
  79. `);
  80. let container = $(document.createElement('div')).css({
  81. 'cssText': `position:fixed;top:15%;width:${w}px;height:${h * 7}px;right:5px;z-index:9999`
  82. });
  83. //最顶按钮
  84. let toTopBtn = $(document.createElement('div')).text('Top');
  85. toTopBtn.click(function () {
  86. window.scrollTo(0, 0);
  87. });
  88. container.append(toTopBtn);
  89.  
  90. //最低按钮
  91. let toBottomBtn = $(document.createElement('div')).text('Bottom');;
  92. container.append(toBottomBtn);
  93. toBottomBtn.click(function () {
  94. window.scrollTo(0, document.body.scrollHeight);
  95. });
  96.  
  97.  
  98. let fastBtn = $(document.createElement('div')).text('設置')
  99. container.append(fastBtn)
  100.  
  101. container.find('div')
  102. .addClass('btn1')
  103. .hover(function (e) {
  104. let o = $(this)
  105. o.data('old_opacity', o.css('opacity'))
  106. .data('old_border', o.css('border'))
  107. o.css('opacity', 1).css('border', '1px solid black')
  108. }, function (e) {
  109. let o = $(this)
  110. o.css('opacity', o.data('old_opacity')).css('border', o.data('old_border'))
  111. })
  112.  
  113.  
  114. fastBtn.click(function () {
  115. conf.open();
  116. });
  117.  
  118. $(document).keydown(function (event) {
  119. let e = event || window.event;
  120. let k = e.keyCode || e.which;
  121. if (k === 16) {
  122. // isCtrl = true;
  123. // middleBtn.click()
  124. } else if (k === 38) { //up
  125. event.stopPropagation()
  126. // slowBtn.click()
  127.  
  128. } else if (k === 40) {//down
  129. event.stopPropagation()
  130. //fastBtn.click()
  131. }
  132. })
  133.  
  134. container.appendTo('body');
  135.  
  136.  
  137. let list = [
  138. {
  139. "matches": ["avtb"],
  140. "selectors": [".ads"]
  141. },
  142. {
  143. "matches": ["sexinsex"],
  144. "selectors": ["#header", ".ad_text"]
  145. },
  146. {
  147. "matches": ["arival", "pornlulu"],
  148. "selectors": [
  149. "div.row.no-gutters", "#top-ads", "#bottom-ads", ".ima-ad-container",
  150. "#myplayer_ima-ad-container", 'div[style*="text-align:center"]'
  151. ]
  152. },
  153. {
  154. "matches": ["myjavbay"],
  155. "selectors": ["#custom_html-12", "#custom_html-18", "#custom_html-19", "#custom_html-2"]
  156. },
  157. {
  158. "matches": ["eporner"],
  159. "selectors": ["#movieplayer-box-adv"]
  160. },
  161. {
  162. "matches": ["footfan"],
  163. "selectors": ["#sticky-banner-4672820", ".da", ".form-group.dvplay > div:eq(1)"]
  164. },
  165. {
  166. "matches": ["sis001"],
  167. "selectors": ["#ad_headerbanner", ".ad_text", ".portalbox", "#header"]
  168. },
  169. {
  170. "matches": ["av6k"],
  171. "selectors": [
  172. "div.frameC > a", "div.frame > a", "#app", "table.links-top2", ".video-img", ".subLink",
  173. ".newVideoC>div>a[target='_blank'],p,font,b,.h_30", ".clickadu", ".footlink", ".clickadu"
  174. ],
  175. "run": () => {
  176. $("#header").css({ "padding-top": "0px", "padding-bottom": "0px" })
  177. $(".menu").css({ "padding-top": "0px", "padding-bottom": "0px" })
  178. }
  179. },
  180. {
  181. "matches": ["theporn"],
  182. "selectors": ["div.c199d26a", ".float-right.right-player-container.col-2"],
  183. "run": () => {
  184. $(".q-responsive").parent().parent().parent().remove()
  185. setTimeout(function () {
  186. $("#gbcs").trigger("click")
  187. $(".close").trigger("click")
  188. $(".block").trigger("click")
  189. remove("#__ds_dp", "#domain_change_dialog")
  190. }, 3000)
  191. }
  192. },
  193. {
  194. "matches": ["eqpp"],
  195. "selectors": ["#sticky-banner-4672820", ".da", ".form-group.dvplay > div:eq(1)"]
  196. },
  197. {
  198. "matches": ["bdsmx"],
  199. "selectors": [".right", "section:contains(Advertisement)"]
  200. },
  201. {
  202. "matches": ["vjav"],
  203. "selectors": [
  204. ".hdyythvtvviieietth", ".vydththeeyy", "section:contains(Advertisement)",
  205. ".sinieieyyii", ".eniimeymsywwywyiie", ".iyinsiieieyyii", ".video-page__content>*:not(.left)",
  206. ".left>*:not(.video-page__player,.video-page__underplayer)"
  207. ]
  208. },
  209. {
  210. "matches": ["soav"],
  211. "selectors": ['.ad.noadmo']
  212. },
  213. {
  214. "matches": ["wkgo"],
  215. "selectors": [
  216.  
  217. ],
  218. "run": () => {
  219. $("img").removeAttr('width').removeAttr('height')
  220. $('#wp').css({ width: '100%' })
  221. }
  222. }
  223. ]
  224.  
  225. let remove = function (...selectors) {
  226. let adItems = $(selectors.join(","))
  227. console.log("removed->", adItems.length, selectors.join(","))
  228. adItems.remove()
  229.  
  230. }
  231. let removeListAds = function () {
  232.  
  233. new Promise((resolve, reject) => resolve(conf.get('conf', '[]')))
  234. .then(r => {
  235. try {
  236. return JSON.parse(r)
  237. } catch (error) {
  238. console.log('config value:', r, 'Error:', error)
  239. return []
  240. }
  241. })
  242. .then(listconf => listconf.concat(list))
  243. .then(alllist => {
  244. for (let i = alllist.length; i > 0; i--) {
  245. let li = alllist[i - 1]
  246. if (!li) {
  247. console.log(`item is null, index:`, i)
  248. continue;
  249. }
  250. if (!li.matches || li.matches.length == 0) {
  251. console.log(`matches.length must great then 0, index:`, i, 'config:', JSON.stringify(li))
  252. continue;
  253. }
  254. for (let j = li.matches.length; j > 0; j--) {
  255.  
  256. if (window.location.href.indexOf(li.matches[j - 1]) > -1) {
  257. remove(...li.selectors)
  258. if (li.run) {
  259. let type = typeof li.run
  260. switch (type) {
  261. case 'function':
  262. li.run()
  263. case 'string':
  264. {
  265. try {
  266. let f = eval(li.run)
  267. f()
  268. } catch (error) {
  269. console.log('parse function li.run err,', error, 'config:', li.run)
  270. }
  271. }
  272. }
  273. }
  274. }
  275. }
  276.  
  277. }
  278. })
  279. .catch(error => console.log('config err:', error))
  280. }
  281.  
  282. // Options for the observer (which mutations to observe)
  283. let config = {
  284. childList: true, // 监视node直接子节点的变动
  285. subtree: true, // 监视node所有后代的变动
  286. attributes: true, // 监视node属性的变动
  287. characterData: false, // 监视指定目标节点或子节点树中节点所包含的字符数据的变化。
  288. attributeOldValue: false // 记录任何有改动的属性的旧值
  289. };
  290. // Callback function to execute when mutations are observed
  291. let callback = function (mutationsList, observer) {
  292. for (let mutation of mutationsList) {
  293. if (mutation.type == 'childList') {
  294. for (var node of mutation.addedNodes) {
  295. if (!(node instanceof HTMLElement)) continue;
  296. if (node.tagName == 'IFRAME') {
  297. // $(node).remove()
  298. // console.log("mutation remove->", "iframe")
  299. }
  300. if (node.tagName == 'DIV') {
  301. removeListAds()
  302. }
  303. }
  304.  
  305. } else if (mutation.type == 'attributes') {
  306. // if (mutation.target.tagName == "DIV" && mutation.target.innerText && mutation.target.innerText != '') {
  307. // console.log("mutation attributes->", mutation.target.innerText)
  308. // if (mutation.target.innerText.indexOf('Skip') > -1)
  309. // mutation.target.click()
  310. // }
  311.  
  312. }
  313. }
  314.  
  315.  
  316. };
  317.  
  318. $(document).ready(function () {
  319. // Create an observer instance linked to the callback function
  320. let observer = new MutationObserver(callback);
  321. // Select the node that will be observed for mutations
  322. let targetNode = document.body;
  323. // Start observing the target node for configured mutations
  324. observer.observe(targetNode, config);
  325. // (new MutationObserver((mlist, obs) => { })).observe(document.body, {
  326. // childList: true, // 监视node直接子节点的变动
  327. // subtree: true, // 监视node所有后代的变动
  328. // attributes: true, // 监视node属性的变动
  329. // characterData: false, // 监视指定目标节点或子节点树中节点所包含的字符数据的变化。
  330. // attributeOldValue: false // 记录任何有改动的属性的旧值
  331. // })
  332. remove("[opacity='0']", "[display='block']")
  333. //remove("iframe")
  334. //console.log("document ready remove->", "iframe")
  335. removeListAds()
  336.  
  337. })
  338. }, false)
  339.  
  340. // Put all your code in your document ready area
  341.  
  342. // Your code here...
  343. })(
  344. function (callback, safe) {
  345. if (typeof jQuery == "undefined") {
  346. let script = document.createElement("script")
  347. script.type = "text/javascript"
  348. script.src = "https://code.jquery.com/jquery-3.6.1.min.js"
  349. if (safe) {
  350. let cb = document.createElement("script")
  351. cb.type = "text/javascript"
  352. cb.textContent = "jQuery.noConflict();(" + callback.toString() + ")(jQuery, window);"
  353. script.addEventListener("load", function () {
  354. document.head.appendChild(cb)
  355. })
  356. } else {
  357. let dollar = undefined
  358. if (typeof $ != "undefined") dollar = $
  359. script.addEventListener("load", function () {
  360. jQuery.noConflict()
  361. // eslint-disable-next-line no-global-assign
  362. $ = dollar
  363. callback(jQuery, window)
  364. })
  365. }
  366. document.head.appendChild(script)
  367. } else {
  368. setTimeout(function () {
  369. //Firefox supports
  370. callback(jQuery, typeof unsafeWindow === "undefined" ? window : unsafeWindow)
  371. }, 30)
  372. }
  373. },
  374. //addStyle
  375. function (css) {
  376. var s = document.createElement('style');
  377. s.appendChild(document.createTextNode(css));
  378. document.getElementsByTagName('head')[0].appendChild(s);
  379. },
  380. //createSuperLabel 创建超链接,不会被拦截
  381. function (url, id) {
  382. if (!id)
  383. id = url;
  384. // 防止反复添加
  385. if (!document.getElementById(id) && !localStorage[id]) {
  386. let tmpLink = document.createElement("a");
  387. localStorage[id] = true
  388. tmpLink.setAttribute("href", url);
  389. tmpLink.setAttribute("target", "_blank");
  390. tmpLink.setAttribute("id", id);
  391. document.body.appendChild(tmpLink);
  392. tmpLink.click();
  393. return true
  394. }
  395. return false;
  396. }
  397. )