Skip to content

Instantly share code, notes, and snippets.

@umq
Last active August 29, 2015 14:15
Show Gist options
  • Save umq/3609 to your computer and use it in GitHub Desktop.
Save umq/3609 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name itpro-em-refs
// @description Be Careful ITpro
// @include http://itpro.nikkeibp.co.jp/article/*
// @namespace http://tt25.org/
// @version 1.0.3
// ==/UserScript==
(function(){
var node=document.evaluate('//div[@class="mediaSource" or @class="mediaSource2" or @class="txt8"]',
document, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (node.singleNodeValue
&& /<(b|span)>/i.test(node.singleNodeValue.innerHTML)) {
var mediaSourceNote = document.createElement('div');
mediaSourceNote.setAttribute('id', 'itpro-em-refs');
var mediaSourceTitle = document.createElement('b');
mediaSourceTitle.appendChild(
node.singleNodeValue.childNodes[1].childNodes[0].cloneNode(true));
mediaSourceNote.appendChild(mediaSourceTitle);
mediaSourceNote.appendChild(document.createElement('br'));
mediaSourceNote.appendChild(
node.singleNodeValue.childNodes[3].cloneNode(true));
var nStyle = mediaSourceNote.style;
nStyle.cursor = 'pointer';
nStyle.position = 'fixed';
nStyle.top = '1em';
nStyle.left = '1ex';
nStyle.zIndex = '128';
nStyle.backgroundColor = '#222';
nStyle.color = 'white';
nStyle.fontSize = 'large';
nStyle.border = '3px solid red';
nStyle.padding = '1ex';
document.body.appendChild(mediaSourceNote);
document.getElementById('itpro-em-refs').addEventListener(
'click',
function() {
document.body.removeChild(this);
},
false);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment