Planets.nu send diplomats to all

Send diplomats to all players

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name          Planets.nu send diplomats to all
// @include       http://planets.nu/*
// @version 0.1
// @description   Send diplomats to all players
// @namespace https://greasyfork.org/users/2874
// ==/UserScript==
function wrapper () { // wrapper for injection

    console.log("sendDiplomats ver: 0.1");
    var old_dipMenu = vgapDashboard.prototype.dipMenu;
    vgapDashboard.prototype.dipMenu = function() {    
        old_dipMenu.apply(this, arguments);
        
        $("#SecondMenu").append("<li onclick='vgap.addOns.sendDiplomats();'>Send Diplomats to All</li>");
    };
    
    vgap.addOns.sendDiplomats = function() {
        for (var i = 0; i < vgap.players.length; i++) {
            var player = vgap.players[i];
            //console.log("Looking: " + player.id + " -> " + JSON.stringify(vgap.getRelation(player.id)));
            if (player.id != vgap.player.id && vgap.getRelation(player.id).relationto == 0) {
                //console.log("Setting: " + player.id);
        		vgap.dash.setRelation(player.id, 1);
            }
        }
    }
    
}
var script = document.createElement("script");
script.type = "application/javascript";
script.textContent = "(" + wrapper + ")();";

document.body.appendChild(script);