Skip to content

Instantly share code, notes, and snippets.

@reallyimeric
Created October 11, 2015 13:57
Show Gist options
  • Select an option

  • Save reallyimeric/ebe30ea1e386b487eb86 to your computer and use it in GitHub Desktop.

Select an option

Save reallyimeric/ebe30ea1e386b487eb86 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name kbnewtab
// @author Eric <[email protected]>
// @icon http://en.gravatar.com/userimage/46203070/0cf34385a83b024fe00c148706ff35a6.png?size=200
// @version 0.2.0
// @description view km in a new tab instead of in original page at kb.ceve-market.org
// @include http://kb.ceve-market.org/*
// @grant GM_registerMenuCommand
// ==/UserScript==
"use strict";
GM_registerMenuCommand("again!",doit,"a");
function doit()
{
var rows;
rows=document.getElementsByClassName("kb-table-row-odd");
for (var i=0;i<rows.length;i++){
if(rows[i].getAttribute("onclick").slice(22,28)!="/kill/")return;
var url='http://kb.ceve-market.org'+rows[i].getAttribute("onclick").slice(22,35); //exp. onclk="window.location.href='/kill/8520615';"
var oclk="window.open(\'"+url+"\', '_blank');";
rows[i].setAttribute("onclick",oclk);
}
rows=document.getElementsByClassName("kb-table-row-even");
for (var i=0;i<rows.length;i++){
if(rows[i].getAttribute("onclick").slice(22,28)!="/kill/")return;
var url='http://kb.ceve-market.org'+rows[i].getAttribute("onclick").slice(22,35); //exp. onclk="window.location.href='/kill/8520615';"
var oclk="window.open(\'"+url+"\', '_blank');";
rows[i].setAttribute("onclick",oclk);
}
}
doit();
var callback=function(records){
records.forEach(function(record) {
/*
console.log('type='+record.type);
console.log('target='+record.target.textContent);
console.log('addedNodes='+record.addedNodes.localName);
console.log(' ');
*/
if (record.type == 'childList') {doit();}
});
}
var mon = new MutationObserver(callback);
var options = {
'childList' : true ,
'subtree' : true
};
mon.observe(document.getElementById("searchresult"), options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment