Last active
November 27, 2019 15:12
-
-
Save Lzs4Kzx3/9f959ab80cb68e2e059931805a556229 to your computer and use it in GitHub Desktop.
Tampermonkey 向けの SearchEngOptPurge
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 SearchEngOptPurgeCore | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description Purge | |
| // @author You | |
| // @match https://www.google.com/search?* | |
| // @match https://www.google.co.jp/search?* | |
| // @match https://search.yahoo.co.jp/* | |
| // @match https://www.bing.com/search?* | |
| // @match http://pasokatu.com/nsearch* | |
| // @match https://duckduckgo.com/?* | |
| // @grant none | |
| // ==/UserScript== | |
| 'use strict'; | |
| window.onload = () => { | |
| let i, j, k; | |
| let len = 0; | |
| let CurrentURL; | |
| let SearchLists, TitleLists; | |
| const NGDList = [ | |
| /soku\.com/, //速報 | |
| /xn--.*o9j0bk/, // まとめ | |
| /jin115\.com/, // jin115 | |
| /matome\.naver\.jp/, // naverまとめ | |
| /blog\.esuteru\.com/, // はちま | |
| /blog\.livedoor\.jp/, // livedoorブログ | |
| /chiebukuro\.yahoo\.co\.jp/, // あれ | |
| ]; | |
| const NGWList = [ | |
| /wwww/, | |
| /と話題に/, | |
| /の理由は/, | |
| /は[\??]/, | |
| /調べてみました/, | |
| /【(PR|PR)】/, | |
| /【(速報|悲報|朗報)】/, | |
| /まとめ(速報|あんてな|アンテナ)/, | |
| ]; | |
| let RemoveList = (i, Links, Title) => { | |
| for (j = NGDList.length - 1; j >= 0; --j) { | |
| if (NGDList[j].test(Links.href)) { | |
| SearchLists[i].parentNode.removeChild(SearchLists[i]); | |
| return; | |
| } | |
| } | |
| for (j = NGWList.length - 1; j >= 0; --j) { | |
| if (NGWList[j].test(Title)) { | |
| SearchLists[i].parentNode.removeChild(SearchLists[i]); | |
| return; | |
| } | |
| } | |
| }; | |
| let Google = () => { | |
| let Links, Title; | |
| let Ad = document.getElementById('taw'); | |
| Ad.parentNode.removeChild(Ad); | |
| let Gsection = document.getElementsByTagName('g-section-with-header'); | |
| for (i = Gsection.length - 1; i >= 0; --i) | |
| Gsection[i].parentNode.removeChild(Gsection[i]); | |
| let Maps = document.getElementsByClassName('vk_c'); | |
| for (i = Maps.length - 1; i >= 0; --i) | |
| Maps[i].parentNode.removeChild(Maps[i]); | |
| let Nrgt = document.getElementsByClassName('nrgt'); | |
| for (i = Nrgt.length - 1; i >= 0; --i) | |
| Nrgt[i].parentNode.removeChild(Nrgt[i]); | |
| let Geo = document.getElementById('fbar'); | |
| Geo.parentNode.removeChild(Geo); | |
| let Ext = document.getElementById('extrares'); | |
| Ext.parentNode.removeChild(Ext); | |
| SearchLists = document.getElementsByClassName('rc'); | |
| let Old = SearchLists[0].childNodes[0].childNodes[0].tagName === 'A'; | |
| for (i = SearchLists.length - 1; i >= 0; --i) { | |
| if (Old) { | |
| Links = SearchLists[i].childNodes[0].getElementsByTagName('a')[0]; | |
| Title = Links.innerText; | |
| } else { | |
| Links = SearchLists[i].childNodes[0].childNodes[1]; | |
| Title = Links.childNodes[2].innerText; | |
| } | |
| RemoveList(i, Links, Title); | |
| } | |
| }; | |
| let Yahoo = () => { | |
| let Links, Title; | |
| let Cmm = document.getElementsByClassName('cmm'); | |
| for (i = Cmm.length - 1; i >= 0; --i) | |
| Cmm[i].parentNode.removeChild(Cmm[i]); | |
| document.getElementById('chie').parentNode.removeChild(document.getElementById('chie')); | |
| let Ad = document.getElementsByClassName('ss'); | |
| for (i = Ad.length - 1; i >= 0; --i) | |
| Ad[i].parentNode.removeChild(Ad[i]); | |
| SearchLists = document.getElementsByClassName('w'); | |
| for (i = SearchLists.length - 1; i >= 0; --i) { | |
| Links = SearchLists[i].childNodes[0].childNodes[0].getElementsByTagName('a')[0]; | |
| Title = Links.innerText; | |
| RemoveList(i, Links, Title); | |
| } | |
| }; | |
| let Bing = () => { | |
| let Links, Title; | |
| let Ans = document.getElementsByClassName('b_ans'); | |
| for (i = Ans.length - 1; i >= 0; --i) | |
| Ans[i].parentNode.removeChild(Ans[i]); | |
| let Ad = document.getElementsByClassName('b_ad'); | |
| for (i = Ad.length - 1; i >= 0; --i) | |
| Ad[i].parentNode.removeChild(Ad[i]); | |
| SearchLists = document.getElementsByClassName('b_algo'); | |
| for (i = SearchLists.length - 1; i >= 0; --i) { | |
| if (SearchLists[i].getElementsByTagName('p')[0] !== void 0){ | |
| if (getComputedStyle(SearchLists[i].getElementsByTagName('p')[0], '::before').getPropertyValue('content') !== 'none') { | |
| SearchLists[i].parentNode.removeChild(SearchLists[i]); | |
| continue; | |
| } | |
| } | |
| if (SearchLists[i].childNodes[0].childNodes[0].tagName === 'A') | |
| Links = SearchLists[i].childNodes[0].getElementsByTagName('a')[0]; | |
| else | |
| Links = SearchLists[i].childNodes[0].childNodes[0].getElementsByTagName('a')[0]; | |
| Title = Links.innerText; | |
| RemoveList(i, Links, Title); | |
| } | |
| }; | |
| let Nsearch = () => { | |
| let Links, Title; | |
| let Ad = document.getElementsByClassName('gsc-adBlock')[0]; | |
| if (Ad !== void 0) | |
| Ad.parentNode.removeChild(Ad); | |
| SearchLists = document.getElementsByClassName('gsc-webResult gsc-result'); | |
| for (i = SearchLists.length - 1; i >= 0; --i) { | |
| Links = SearchLists[i].childNodes[0].childNodes[0].childNodes[0].getElementsByTagName('a')[0]; | |
| Title = Links.innerText; | |
| RemoveList(i, Links, Title); | |
| } | |
| }; | |
| let NsearchTop = () => { | |
| const target = document.getElementsByClassName('gsc-results-wrapper-nooverlay')[0]; | |
| const observer = new MutationObserver((mutations) => { | |
| NsearchChange(); | |
| }); | |
| const config = { | |
| attributes: true | |
| }; | |
| observer.observe(target, config); | |
| }; | |
| let NsearchChange = () => { | |
| Nsearch(); | |
| const target = document.getElementsByClassName('gsc-resultsbox-visible')[0]; | |
| const observer = new MutationObserver((mutations) => { | |
| Nsearch(); | |
| }); | |
| const config = { | |
| attributes: true | |
| }; | |
| observer.observe(target, config); | |
| }; | |
| let Duckduckgo = () => { | |
| let Links, Title; | |
| SearchLists = Array.from(new Set(document.getElementsByClassName('results_links_deep highlight_d'))); | |
| for (i = SearchLists.length - 1; i >= len; --i) { | |
| Links = SearchLists[i].childNodes[0].childNodes[0].getElementsByTagName('a')[0]; | |
| Title = Links.innerText; | |
| RemoveList(i, Links, Title); | |
| } | |
| len = Array.from(new Set(document.getElementsByClassName('results_links_deep highlight_d'))).length; | |
| }; | |
| let DuckduckgoChange = () => { | |
| const target = document.getElementById('links'); | |
| const observer = new MutationObserver((mutations) => { | |
| Duckduckgo(); | |
| }); | |
| const config = { | |
| childList: true | |
| }; | |
| observer.observe(target, config); | |
| }; | |
| CurrentURL = location.href; | |
| if (/https?:\/\/www\.google\.(com|co\.jp)\/search\?*/.test(CurrentURL)) { | |
| Google(); | |
| } else if (/https?:\/\/search\.yahoo\.co\.jp\/search\?*/.test(CurrentURL)) { | |
| Yahoo(); | |
| } else if (/https?:\/\/www\.bing\.com\/search\?*/.test(CurrentURL)) { | |
| Bing(); | |
| } else if (/pasokatu\.com\/nsearch#gsc\.tab=0*/.test(CurrentURL)) { | |
| /pasokatu\.com\/\/duckduckgo\.com\/\?*/.test(CurrentURL) ? NsearchTop(): NsearchChange(); | |
| } else if (/https?:\/\/duckduckgo\.com\/\?*/.test(CurrentURL)) { | |
| Duckduckgo(); | |
| DuckduckgoChange(); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment