Created
November 12, 2012 14:47
-
-
Save gyuque/4059801 to your computer and use it in GitHub Desktop.
手対策
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 nohand | |
// @namespace gyuque | |
// @include https://plus.google.com/* | |
// @include http://plus.google.com/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
var TE = /108977285290207653060$/ ; | |
function eachElement(tagName, func) { | |
var ls = document.getElementsByTagName(tagName); | |
var len = ls.length; | |
for (var i = 0;i < len;++i) { | |
func(ls[i]); | |
} | |
} | |
function findParentElement(origin, iteration, tagName) { | |
var el = origin.parentNode; | |
for (var i = 0;i < 10 && !!el;++i) { | |
if (el.tagName.toLowerCase() == tagName) { | |
if (--iteration < 1) { | |
return el; | |
} | |
} | |
el = el.parentNode; | |
} | |
} | |
function setup() { | |
eachElement('a', function(el){ | |
if (el.getAttribute("nohand-enabled")) { | |
return; | |
} | |
if (TE.test(el.href)) { | |
el.setAttribute("nohand-enabled", "yes"); | |
var container = findParentElement(el, 2, 'div'); | |
container.style.opacity = 0.3; | |
container.addEventListener("click", function(){ | |
container.style.opacity = ''; | |
}, false); | |
} | |
}); | |
} | |
setup(); | |
document.addEventListener('DOMNodeInserted', setup, false); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment