-
-
Save mactkg/de106fd12b8878578aec 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
/* | |
hatenaCardBackgroundChanger | |
@3846masa | |
iframeの属性にbackgroundを追加してcss方式で書くとなる(多分)。 | |
*/ | |
window.addEventListener('load',function(){ | |
var list = document.querySelectorAll('iframe[src*="http://hatenablog.com/embed"][background]'); | |
Array.prototype.forEach.call(list, function(node){ | |
var div = document.createElement('div'); | |
div.classList.add('hatenacard-wrap'); | |
div.style.position = 'relative'; | |
var innerDiv = document.createElement('div'); | |
innerDiv.style.cssText = 'position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0.1;'; | |
innerDiv.style.background = node.getAttribute('background'); | |
div.insertBefore(innerDiv, null); | |
node.parentNode.insertBefore(div, node); | |
div.insertBefore(node, innerDiv); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment