CotG Horizon

This script adds some buttons to send settleorders to our alliancebot

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name                CotG Horizon
// @description	        This script adds some buttons to send settleorders to our alliancebot
// @author         		Darius83
// @include				https://w*.crownofthegods.com/World00.php
// @version				1.0.5
// @grant none
// @namespace https://greasyfork.org/users/117592
// ==/UserScript==
 
/*jshint esnext: true */

(function(){
	// Debug Mode an-/ausschalten
	var DEBUG = false;
	var SCRIPTNAME = GM_info.script.name;
	var VERSION = GM_info.script.version;

	var textfeld = document.getElementById('chatMsg');
	var sendButton = document.getElementById('sendChat');
	var clickEvent = new MouseEvent("click", {
		"view": window,
		"bubbles": true,
		"cancelable": false
	});
	var regex = /\d{1,3}:\d{1,3}/;

	var buttonWhispSettle = document.createElement('button');
	var buttonWhispSettleText = document.createTextNode('!settle xxx:yyy');
	var buttonWhispSettleDel = document.createElement('button');
	var buttonWhispSettleDelText = document.createTextNode('!settle del xxx:yyy');
	var buttonWhispSettleInfo = document.createElement('button');
	var buttonWhispSettleInfoText = document.createTextNode('settle xxx:yyy');

	buttonWhispSettle.appendChild(buttonWhispSettleText);
	buttonWhispSettle.setAttribute('class', 'regButton greenbuttonGo greenb');
	buttonWhispSettle.style.margin = '2% 0 0 2%';
	buttonWhispSettle.style.maxWidth = '30%';

	buttonWhispSettleDel.appendChild(buttonWhispSettleDelText);
	buttonWhispSettleDel.setAttribute('class', 'regButton greenbuttonGo greenb');
	buttonWhispSettleDel.style.margin = '2% 0 0 2%';
	buttonWhispSettleDel.style.maxWidth = '30%';

	buttonWhispSettleInfo.appendChild(buttonWhispSettleInfoText);
	buttonWhispSettleInfo.setAttribute('class', 'regButton greenbuttonGo greenb');
	buttonWhispSettleInfo.style.margin = '2% 0 0 2%';
	buttonWhispSettleInfo.style.maxWidth = '30%';

	if (typeof window.localStorage != "undefined") {
		var cotgScripts = localStorage.getItem("CotG_Scripts");
		if (cotgScripts === null) {
			cotgScripts = new Array();
			cotgScripts[0] = [SCRIPTNAME, VERSION];
			localStorage.setItem("CotG_Scripts", JSON.stringify(cotgScripts));
		} else {
			cotgScripts = JSON.parse(cotgScripts);
			for (var i = 0; i < cotgScripts.length; i++) {
				if (cotgScripts[i][0] === SCRIPTNAME) {
					if (cotgScripts[i][1] === VERSION) {
						break;
					} else {
						cotgScripts[i][1] = VERSION;
						localStorage.setItem("CotG_Scripts", JSON.stringify(cotgScripts));
						break;
					}
				}
				if (i === cotgScripts.length - 1) {
					if (cotgScripts[i][1] != SCRIPTNAME) {
						cotgScripts[i+1] = [SCRIPTNAME, VERSION];
						localStorage.setItem("CotG_Scripts", JSON.stringify(cotgScripts));
					}
				}
			}
		}
	}

	buttonWhispSettleInfo.addEventListener("click", function()
	{
		// /w Mother settle xxx:yyy
		var coords = document.getElementById('emptysInfo').innerHTML.match(regex);
		textfeld.value = '/w Mother settle '+coords;
		sendButton.dispatchEvent(clickEvent);
	}, false);

	buttonWhispSettle.addEventListener("click", function()
	{
		// /w Mother !settle xxx:yyy
		var coords = document.getElementById('emptysInfo').innerHTML.match(regex);
		textfeld.value = '/w Mother !settle '+coords;
		sendButton.dispatchEvent(clickEvent);
	}, false);

	buttonWhispSettleDel.addEventListener("click", function()
	{
		// /w Mother !settle del xxx:yyy
		var coords = document.getElementById('emptysInfo').innerHTML.match(regex);
		textfeld.value = '/w Mother !settle del '+coords;
		sendButton.dispatchEvent(clickEvent);
	}, false);

	var div1 = document.getElementById('squareemptyspot');
	div1.appendChild(buttonWhispSettleInfo);
	div1.appendChild(buttonWhispSettle);
	div1.appendChild(buttonWhispSettleDel);
})();