Page enhancer


Introducing the game page enhancer!

This is a bit of javascript code that will remove everything from an NK game page except for the game itself, additionally disabling the 'are you sure you want to leave the page' popup, and immediately skipping a video advert (even if it claims to be unskippable!)

Just in case you find yourself with a lack of adblock, or perhaps you simply prefer to use the main page over the direct swf, but would like it even better if it were more plain and didn't inhibit your ability to leave. Indeed, that's the situation I found myself in that encouraged me to write it.

Without further ado, here's the code:

javascript:(function(){var e,i,j,c,s=[];window.onbeforeunload="";removeAdSwf();e=document.getElementById("play-page");if(e)e.style.margin="0px";e=document.getElementById("content");if(e){e.style.backgroundColor="#000000";e.style.display="table";e.style.position="absolute";e.style.width="100%";e.style.height="100%"}e=document.getElementById("primary");if(e){e.style.display="table-cell";e.style.verticalAlign="middle"}e=document.getElementById("game_container");if(!e)e=document.getElementById("unityPlayer");if(e){e.style.marginLeft="auto";e.style.marginRight="auto";e.style.cssFloat="left";s.push(e)}e=document.getElementById("preroll");if(e)s.push(e);e=document.getElementsByTagName("title");for(i=e.length-1;i>=0;i--)s.push(e[i]);e=document.getElementsByTagName("*");for(i=e.length-1;i>=0;i--){if(s.indexOf(e[i])>-1)continue;if(e[i].tagName.toLowerCase()!=="iframe"){c=0;for(j=0;j<s.length;j++){if(s[j].contains(e[i])||e[i].contains(s[j])){c=1;break}}if(c===1)continue;}e[i].parentNode.removeChild(e[i])}})();

To use:

  • Option 1: create a bookmark, paste this code where you would normally put a URL, then simply click the bookmark whenever you want to run it.
  • Option 2 (slightly more technical): obtain the Greasemonkey or Tampermonkey plugin, set up a script for the game pages you're interested in, containing the above code. Well, most of it - it shouldn't have the 'javascript:' at the start.