GOTA_Container

Modifies the container in which the game is hosted (optionally).

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        GOTA_Container
// @namespace   gota_container
// @description Modifies the container in which the game is hosted (optionally).
// @include     https://games.disruptorbeam.com/gamethrones*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @version     1.2
// @grant       GM_getValue
// @grant       GM_setValue
// @grant       unsafeWindow
// ==/UserScript==

// Resolve jQuery conflicts
this.$ = this.jQuery = jQuery.noConflict(true);

// Button HTML definition
var hideHeaderLink = '<a href="#" id="hideHeader">Hide header</a>';
var showGameOnly = '<a href="http://gota-www.disruptorbeam.com/" id="showGameOnly">Show game only</a>&nbsp;';

$(function() {
    try {

        // Append button        
        var $header = $("header.site-header");
        if ($header && $header.length > 0) {
            $header.before(showGameOnly);
            $header.before(hideHeaderLink);
        }

        var $hideLnk = $("#hideHeader");
        if (!$hideLnk && $hideLnk.length == 0) {
            warn("Could not append link button.");
        }

        (function() {
            // Fix iframe visual bugs in FF
            var $iframe = $("#iframe_content iframe");
            if (!$iframe || $iframe.length == 0) {
                return;
            }

            $iframe.css("display", "inline");
            $iframe.css("height", "1000px");
            $iframe.attr("id", "gota_iframe");

            GM_getValue("hideHeader", false)
                ? ($header.show(), $hideLnk.text("Hide header"))
                : ($header.hide(), $hideLnk.text("Show header"));
        })();

        // Attach handler on the buttons
        $("#hideHeader").on('click', function(e) {
            e.preventDefault();

            if (!$header || $header.length == 0) {
                error("Could not locate header.");
                return;
            }

            $header.is(":hidden")
                ? ($header.show(), $hideLnk.text("Hide header"))
                : ($header.hide(), $hideLnk.text("Show header"));

            GM_setValue("hideHeader", $header.is(":hidden"));
        });

        inject(scope.toString());

    } catch (err) {
        error("Error encountered: " + err);
    }
});

function inject(code) {

    var script = document.createElement('script');
    script.type = "text/javascript";
    script.innerHTML = code;
    document.head.appendChild(script);

}

// --> Message handling
function log(message, type) {
    if (console && console.log && typeof (console.log) == "function") {
        if (!type)
            type = "ex-container";

        var prefix = type.toString().toUpperCase() + " <" + new Date().toLocaleTimeString() + "> ";
        console.log(prefix + message);
    }
}

function error(message, type) {
    if (console && console.error && typeof (console.error) == "function") {
        if (!type)
            type = "ex-container";

        var prefix = type.toString().toUpperCase() + " - ERROR <" + new Date().toLocaleTimeString() + "> ";
        console.error(prefix + message);
    }
}

function warn(message, type) {
    if (console && console.warn && typeof (console.warn) == "function") {
        if (!type)
            type = "ex-container";

        var prefix = type.toString().toUpperCase() + " - WARNING <" + new Date().toLocaleTimeString() + "> ";
        console.warn(prefix + message);
    }
}

function scope(data) {
    //console.debug("Attempting to post data to the frame, data: " + data);
    window.frames[0].postMessage(data, "https://gota-www.disruptorbeam.com");
    return data;
}