Skip to content

Instantly share code, notes, and snippets.

@mactkg
Forked from 3846masa/hatenaCardBgChanger.js
Created September 29, 2014 06:43
Show Gist options
  • Save mactkg/de106fd12b8878578aec to your computer and use it in GitHub Desktop.
Save mactkg/de106fd12b8878578aec to your computer and use it in GitHub Desktop.
/*
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