Skip to content

Instantly share code, notes, and snippets.

@ambar
Created December 10, 2011 14:05
Show Gist options
  • Save ambar/1455243 to your computer and use it in GitHub Desktop.
Save ambar/1455243 to your computer and use it in GitHub Desktop.
UserScripts
// ==UserScript==
// @name Disguise Surfing
// @namespace anonymous
// @description 伪装上网模式
// @version 0.1
// @include *
// ==/UserScript==
// make array
var $A = function(obj) { return [].slice.call(obj) }
// 需要隐藏的列表
var list = ['长天之云','longsky'];
// 需要伪装成啥
var repl = '小小马甲';
var regex = new RegExp(list.join('|'),'g');
var disguise = function(node) {
node.textContent = node.textContent.replace(regex,repl);
}
// 搜寻所有文本节点 Node.TEXT_NODE = 3
// *兼容问题, firefox GreaseMonkey 中环境特殊, Node 构造器上得不到 TEXT_NODE 到值
var traverse = function(iterator) {
$A( document.querySelectorAll('*') )
.forEach(function(node){
$A( node.childNodes )
.filter(function(node) {
return node.nodeType === 3
})
.forEach(iterator)
});
}
if( document.readyState === 'complete' ){
traverse(disguise)
}else{
document.addEventListener("DOMContentLoaded", function() {
traverse(disguise)
}, false)
}
// ==UserScript==
// @name Baidu Tieba
// @namespace nil
// @description 去广告,去 autofocus
// @version 0.1
// @include http://tieba.baidu.com/p/*
// ==/UserScript==
$ = document.querySelector.bind(document)
rm = function(el) { el.parentNode.removeChild(el) }
rm( $('#loginForm0') )
rm( $('#rightAd') )
rm( $('div.l_banner') )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment