Mutik's DotD Script

Fork of ForTheGoodOfAll DotD script with new look and strongly optimized js code

Tính đến 02-06-2014. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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

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

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

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           Mutik's DotD Script
// @namespace      tag://kongregate
// @description    Fork of ForTheGoodOfAll DotD script with new look and strongly optimized js code
// @author         Mutik, orig version: SReject, chairmansteve, tsukinomai(Shylight)?, JHunz, wpatter6, MoW, true_heathen, HG, mutikt, PDrifting
// @version        1.0.17
// @grant          GM_xmlhttpRequest
// @include        http://www.kongregate.com/games/5thPlanetGames/dawn-of-the-dragons*
// @include        *web*.dawnofthedragons.com/*
// @include        http://dotd.url.ph/*
// ==/UserScript==

function main() {
    if (typeof GM_setValue === 'undefined') {
        var GM_setValue = function (name, value) { localStorage.setItem(name, (typeof value).substring(0, 1) + value); };
    }
    if (typeof GM_getValue == 'undefined') {
        var GM_getValue = function (name, dvalue) {
            var value = localStorage.getItem(name);
            if (typeof value != 'string') return dvalue;
            else {
                var type = value.substring(0, 1);
                value = value.substring(1);
                if (type == 'b') return (value == 'true');
                else if (type == 'n') return Number(value);
                else return value;
            }
        };
    }
    if (typeof GM_deleteValue == 'undefined') var GM_deleteValue = function(name) { localStorage.removeItem(name) };

    window.FPX = {
		LandBasePrices:[4000,15000,25000,50000,75000,110000,300000,600000,1200000],
        LandBaseIncome:[100,300,400,700,900,1200,2700,4500,8000],
        LandCostRatio: function(owned) {
            var landCosts = [4000,15000,25000,50000,75000,110000,300000,600000,1200000];
            var icr = [1,1,1,1,1,1,1,1,1]; /*Income/Cost ratio*/
            var i = 9;
            while (i--) {
                landCosts[i] += FPX.LandBasePrices[i] * owned[i] / 10;
                icr[i] = FPX.LandBaseIncome[i] / landCosts[i];
            }
            return icr;
        }
	};
	window.timeSince = function(date,after) {
        if (typeof date === 'number') date = new Date(date);
        var seconds = Math.abs(Math.floor((new Date().getTime() - date.getTime())/1000));
        var interval = Math.floor(seconds/31536000);
        var pretext = 'about ', posttext = after ? ' left' : ' ago';
        if (interval >= 1) return pretext + interval + ' year' + (interval == 1 ? '' : 's') + posttext;
        interval = Math.floor(seconds/2592000);
        if (interval >= 1) return pretext + interval + ' month' + (interval == 1 ? '' : 's') + posttext;
        interval = Math.floor(seconds/86400);
        if (interval >= 1) return pretext + interval + ' day' + (interval == 1 ? '' : 's') + posttext;
        interval = Math.floor(seconds/3600);
        if (interval >= 1) return pretext + interval + ' hour' + (interval == 1 ? '' : 's') + posttext;
        interval = Math.floor(seconds/60);
        if (interval >= 1) return interval + ' minute' + (interval == 1 ? '' : 's') + posttext;
        return Math.floor(seconds) + ' second' + (seconds == 1 ? '' : 's') + posttext;
    };
	window.isNumber = function(n) { return !isNaN(parseFloat(n)) && isFinite(n); };
	window.SRDotDX = {
		version: { major: "1.0.17", minor: 'Mutik\'s mod' },
        util: {
            getQueryVariable: function(v, s){
                var query = String(s||window.location.search.substring(1));
                if(query.indexOf('?')>-1) query = query.substring(query.indexOf('?')+1);
                var vars = query.split('&');
                for (var i = 0; i < vars.length; i++) {
                    var pair = vars[i].split('=');
                    if (decodeURIComponent(pair[0]) == v) {
                        return decodeURIComponent(pair[1]);
                    }
                }
                return ''
            },
            getRaidFromUrl: function(url){
                var r = {}, link;
                var reg = /[?&]([^=]+)=([^?&]+)/ig, p = url.replace(/&amp;/gi,"&");
                while (link = reg.exec(p)) {
                    if (!r.diff && link[1] == 'kv_difficulty') r.diff = parseInt(link[2]);
                    else if (!r.hash && link[1] == 'kv_hash') r.hash = link[2];
                    else if (!r.boss && link[1] == 'kv_raid_boss') r.boss = link[2];
                    else if (!r.id && link[1] == 'kv_raid_id') r.id = link[2].replace(/http:?/i,"");
                    else if (link[1] != 'kv_action_type') return null;
                }
                return r;
            },
            getShortNum: function (num) {
                if (isNaN(num) || num < 0) return num;
                if (num >= 1000000000000) return (num / 1000000000000).toPrecision(4) + 't';
                if (num >= 1000000000) return (num / 1000000000).toPrecision(4) + 'b';
                if (num >= 1000000) return (num / 1000000).toPrecision(4) + 'm';
                if (num >= 1000) return (num / 1000).toPrecision(4) + 'k';
                return num + ''
            },
            objToUriString: function(obj) {
                if (typeof obj == 'object') {
                    var str = '';
                    for (var i in obj) str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]) + '&'; str = str.substring(0,str.length-1);
                    return str
                } return '';
            },
            serialize: function(obj) {
                var str = [];
                for (var p in obj) if(obj[p]!=null)str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                return str.join("&");
            },
            stringFormat: function() {
                var s = arguments[0];
                for (var i = 0; i < arguments.length - 1; i++) {
                    var reg = new RegExp("\\{" + i + "\\}", "gm");
                    s = s.replace(reg, arguments[i + 1]);
                }
                return s;
            }
        },
		config: (function() {
            var tmp, reqSave = false;
			try { tmp = JSON.parse(GM_getValue('SRDotDX','{}')) }
			catch (e) { tmp = {}; reqSave = true }
            //Raids tab vars
            tmp.lastFilter = typeof tmp.lastFilter == 'string' ? tmp.lastFilter : '';
            tmp.filterSearchStringR = typeof tmp.filterSearchStringR == 'string' ? tmp.filterSearchStringR : '';
            tmp.fltIncVis = typeof tmp.fltIncVis == 'boolean' ? tmp.fltIncVis : false;
            tmp.fltShowNuked = typeof tmp.fltShowNuked == 'boolean' ? tmp.fltShowNuked : false;
            tmp.fltShowAll = typeof tmp.fltShowAll == 'boolean' ? tmp.fltShowAll : false;

            //Options tab vars
            tmp.importFiltered = typeof tmp.importFiltered == 'boolean' ? tmp.importFiltered : true;
			tmp.hideRaidLinks = typeof tmp.hideRaidLinks == 'boolean' ? tmp.hideRaidLinks : false;
            tmp.hideBotLinks = typeof tmp.hideBotLinks == 'boolean' ? tmp.hideBotLinks : false;
            tmp.hideVisitedRaids = typeof tmp.hideVisitedRaids == 'boolean' ? tmp.hideVisitedRaids : false;
            tmp.hideVisitedRaidsInRaidList = typeof tmp.hideVisitedRaidsInRaidList == 'boolean' ? tmp.hideVisitedRaidsInRaidList : false;
            tmp.markMyRaidsVisted = typeof tmp.markMyRaidsVisted == 'boolean' ? tmp.markMyRaidsVisted : false;
            tmp.markImportedVisited = typeof tmp.markImportedVisited == 'boolean' ? tmp.markImportedVisited : false;
            tmp.FPXLandOwnedCount = typeof tmp.FPXLandOwnedCount == 'object' ? tmp.FPXLandOwnedCount : [0, 0, 0, 0, 0, 0, 0, 0, 0];
            tmp.prettyPost = typeof tmp.prettyPost == 'boolean' ? tmp.prettyPost : false;
            tmp.useMaxRaidCount = typeof tmp.useMaxRaidCount == 'boolean' ? tmp.useMaxRaidCount : false;
            tmp.maxRaidCount = !(typeof tmp.maxRaidCount === 'undefined') ? tmp.maxRaidCount : 3000;
            tmp.autoImportPaste = typeof tmp.autoImportPaste == 'boolean' ? tmp.autoImportPaste : false;
            tmp.confirmForLargePaste = typeof tmp.confirmForLargePaste == 'boolean' && tmp.confirmPasteSize ? tmp.confirmForLargePaste : false;
            tmp.confirmPasteSize = typeof tmp.confirmPasteSize == 'number' ? tmp.confirmPasteSize : 1000;
            tmp.showStatusOverlay = typeof tmp.showStatusOverlay == 'boolean' ? tmp.showStatusOverlay : false;
            tmp.confirmDeletes = typeof tmp.confirmDeletes == 'boolean' ? tmp.confirmDeletes : true;
            tmp.autoPostPaste = typeof tmp.autoPostPaste == 'boolean' ? tmp.autoPostPaste : false;
            tmp.whisperTo = typeof tmp.whisperTo == 'string' ? tmp.whisperTo : '';
            tmp.formatLinkOutput = typeof tmp.formatLinkOutput == 'boolean' ? tmp.formatLinkOutput : false;
            tmp.linkShowFs = typeof tmp.linkShowFs == 'boolean' ? tmp.linkShowFs : false;
            tmp.linkShowAp = typeof tmp.linkShowAp == 'boolean' ? tmp.linkShowAp : false;
            tmp.unvisitedRaidPruningMode = typeof tmp.unvisitedRaidPruningMode == 'number' ? tmp.unvisitedRaidPruningMode : 1;
            tmp.selectedRaids = typeof tmp.selectedRaids == 'string' ? tmp.selectedRaids : '';
            tmp.pastebinUrl = typeof tmp.pastebinUrl == 'string' ? tmp.pastebinUrl : '';
            tmp.bckColor = typeof tmp.bckColor == 'string' ? tmp.bckColor : 'fff';
            tmp.lastImported = typeof tmp.lastImported == 'number' ? tmp.lastImported : ((new Date).getTime() - 1728000000);
            tmp.hideKongForum = typeof tmp.hideKongForum == 'boolean' ? tmp.hideKongForum : false;
            tmp.hideGameDetails = typeof tmp.hideGameDetails == 'boolean' ? tmp.hideGameDetails : false;
            tmp.hideGameTitle = typeof tmp.hideGameTitle == 'boolean' ? tmp.hideGameTitle : true;
            tmp.chatFilterString = typeof tmp.chatFilterString == 'string' ? tmp.chatFilterString : '';
            tmp.filterSearchStringC = typeof tmp.filterSearchStringC == 'string' ?