Last active
August 29, 2015 14:22
-
-
Save igromanru/36bf7d38d7d26e140b06 to your computer and use it in GitHub Desktop.
GalaxyScan
This file contains hidden or 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
| // ==UserScript== | |
| // @name GalaxyScan | |
| // @namespace IgroGalaxyScan | |
| // @author Igromanru | |
| // @include *.ogame.gameforge.com/game/index.php?page=galaxy* | |
| // @description Browsing through the Universe to get the data for GalaxyTool | |
| // @version 0.1 | |
| // @grant none | |
| // ==/UserScript== | |
| var scriptFunc = (function() { | |
| $.fn.exists = function () { | |
| return this.length !== 0; | |
| }; | |
| }).toString(); | |
| function getElementByXpath(path) { | |
| return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
| } | |
| function injectScript (myFunc) { | |
| var script = document.createElement ("script"); | |
| script.setAttribute ("type", "application/javascript"); | |
| script.textContent = "(" + myFunc + ") ();"; | |
| document.body.appendChild (script); | |
| } | |
| function injectHtml() { | |
| var buttonsDiv = getElementByXpath("//tr[@id='galaxyheadbg']/td/div"); | |
| var scanDiv = document.createElement('div'); | |
| scanDiv.setAttribute('id',"scanGalaxyButton"); | |
| scanDiv.innerHTML = '<a id="buttonScanGalaxy" onclick="doScanGalaxy();" href="javascript:void(0);"><span class="bleft"></span><span class="text">Scan Galaxy</span><span class="bright"></span></a>'; | |
| buttonsDiv.appendChild(scanDiv); | |
| } | |
| function injectCss() { | |
| var scanButtonCss = '#buttonScanGalaxy { color: #fff; display: block } #buttonScanGalaxy:hover { color: #9c0; }'; | |
| var style = document.createElement('style'); | |
| style.type = 'text/css'; | |
| style.innerHTML = scanButtonCss; | |
| document.getElementsByTagName("head")[0].appendChild(style); | |
| } | |
| if (document.body) { | |
| //injectScript(scriptFunc); | |
| injectHtml(); | |
| injectCss(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment