Created
May 10, 2019 00:52
-
-
Save FaiChou/256ce2839563f3d303e18f5db0db1998 to your computer and use it in GitHub Desktop.
A tampermonkey script to filter bad information searching on google
This file contains 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 GoogleSearchFilter | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description filter google search! | |
// @author FaiChou | |
// @match https://www.google.com/search* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var MObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; | |
var blockRules = /codeday.me|android.stackovernet.com|blog.csdn.net/; | |
function filterSearchList() { | |
var searchList = document.getElementsByClassName('g'); | |
var queryNum = searchList.length; | |
for (var i = 0; i < queryNum; i++) { | |
var item = searchList[i]; | |
var citeCollection = item.getElementsByTagName('cite'); | |
if (citeCollection.length !== 0) { | |
var innerUrl = citeCollection[0].innerText; | |
if (blockRules.test(innerUrl)) { | |
item.remove(); | |
} | |
} | |
} | |
} | |
var observer = new MObserver(filterSearchList); | |
observer.observe(document.body, { childList: true }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment