您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Copy & Paste selected world object coords to chat message
// ==UserScript== // @name C&C:Tiberium Alliances Coords Button - All // @namespace CNCTACoordsButtonAll // @description Copy & Paste selected world object coords to chat message // @include https://prodgame*.alliances.commandandconquer.com/*/index.aspx* // @version 2.0.2 // @author Bruce Doan, Chiantii // ==/UserScript== (function () { var CNCTACoordsButtonAll_main = function () { try { function createCoordsButton() { console.log('C&C:Tiberium Alliances Coords Button All loaded.'); /* $a = qx.core.Init.getApplication(); // Application $c = $a.getChat(); // ChatWindow $w = $c.getChatWidget(); // ChatWidget $i = $cw.getEditable(); // Input $d = $i.getContentElement().getDomElement(); // Input DOM Element */ var coordsButton = { selectedBase: null, pasteCoords: function(){ var $i = qx.core.Init.getApplication().getChat().getChatWidget().getEditable(); // Input var $d = $i.getContentElement().getDomElement(); // Input DOM Element var result = new Array(); result.push($d.value.substring(0,$d.selectionStart)); // start result.push('[coords]' + coordsButton.selectedBase.get_RawX() + ':' + coordsButton.selectedBase.get_RawY() + '[/coords]'); result.push($d.value.substring($d.selectionEnd, $d.value.length)); // end $i.setValue(result.join(' ')); } }; if (!webfrontend.gui.region.RegionCityMenu.prototype.__coordsButton_showMenu) { webfrontend.gui.region.RegionCityMenu.prototype.__coordsButton_showMenu = webfrontend.gui.region.RegionCityMenu.prototype.showMenu; webfrontend.gui.region.RegionCityMenu.prototype.showMenu = function (selectedVisObject) { coordsButton.selectedBase = selectedVisObject; if (this.__coordsButton_initialized != 1) { this.__coordsButton_initialized = 1; this.__newComposite = new qx.ui.container.Composite(new qx.ui.layout.VBox(0)).set({ padding: 2 }); for(i in this) { if(this[i] && this[i].basename == "Composite") { var button = new qx.ui.form.Button("Paste Coords"); button.addListener("execute", function () { coordsButton.pasteCoords(); }); this[i].add(button); } } } this.__coordsButton_showMenu(selectedVisObject); switch (selectedVisObject.get_VisObjectType()) { case ClientLib.Vis.VisObject.EObjectType.RegionPointOfInterest: case ClientLib.Vis.VisObject.EObjectType.RegionRuin: case ClientLib.Vis.VisObject.EObjectType.RegionHubControl: case ClientLib.Vis.VisObject.EObjectType.RegionHubServer: this.add(this.__newComposite); break; } } } } } catch (e) { console.log("createCoordsButton: ", e); } function CNCTACoordsButtonAll_checkIfLoaded() { try { if (typeof qx !== 'undefined') { createCoordsButton(); } else { window.setTimeout(CNCTACoordsButtonAll_checkIfLoaded, 1000); } } catch (e) { console.log("CNCTACoordsButtonAll_checkIfLoaded: ", e); } } window.setTimeout(CNCTACoordsButtonAll_checkIfLoaded, 1000); }; try { var CNCTACoordsButtonAll = document.createElement("script"); CNCTACoordsButtonAll.innerHTML = "(" + CNCTACoordsButtonAll_main.toString() + ")();"; CNCTACoordsButtonAll.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(CNCTACoordsButtonAll); } catch (e) { console.log("CNCTACoordsButtonAll: init error: ", e); } })();