Skip to content

Instantly share code, notes, and snippets.

@gyuque
Created November 12, 2012 14:47
Show Gist options
  • Save gyuque/4059801 to your computer and use it in GitHub Desktop.
Save gyuque/4059801 to your computer and use it in GitHub Desktop.
手対策
// ==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