Last active
March 22, 2016 04:25
-
-
Save oboenikui/cf6feebf7c8a3f1351de to your computer and use it in GitHub Desktop.
Twitter Web Clientで画像を隠すやつ (URLマウスオーバーで表示)
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
(function() { | |
var style = document.createElement("style"); | |
style.innerText = ".AdaptiveMedia{display: none !important}\n.twitter-timeline-link.u-hidden{display: block !important}"; | |
document.head.appendChild(style); | |
var setMouseOver = function(selectedElements) { | |
var hidden; | |
if(selectedElements) { | |
hidden = selectedElements.find(".twitter-timeline-link.u-hidden"); | |
} else { | |
hidden = $(".twitter-timeline-link.u-hidden"); | |
} | |
hidden.on("mouseover", function(ev){ | |
ev.target.setAttribute("keep-mouseover", ""); | |
setTimeout(function(){ | |
if(ev.target.getAttribute("keep-mouseover") !== null){ | |
var adaptiveMedia = $(ev.target).closest(".tweet").find(".AdaptiveMedia"); | |
adaptiveMedia.css({cssText: "display:block !important"}); | |
} | |
}, 500); | |
}); | |
hidden.on("mouseout", function(ev){ | |
ev.target.removeAttribute("keep-mouseover"); | |
setTimeout(function(){ | |
if(ev.target.getAttribute("keep-mouseover") === null){ | |
var adaptiveMedia = $(ev.target).closest(".tweet").find(".AdaptiveMedia"); | |
adaptiveMedia.css({cssText: ""}); | |
} | |
}, 1000); | |
}); | |
}; | |
setMouseOver(); | |
var mo = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
if(mutation.addedNodes.length !== 0) { | |
for(var i=0; i<mutation.addedNodes.length; i++) { | |
setMouseOver($(mutation.addedNodes[i])); | |
} | |
} | |
}); | |
}); | |
mo.observe(document, {childList: true, subtree: true}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment