GM_update Tester

GM_Update is a library that allows you to update your script from any site that support meta.js standard or the main USO alternatives: OpenUserJS, Greasy Fork and MonkeyGuts.

目前為 2014-10-04 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name                GM_update Tester
// @namespace           TimidScript
// @description         GM_Update is a library that allows you to update your script from any site that support meta.js standard or the main USO alternatives: OpenUserJS, Greasy Fork and MonkeyGuts.
// @include             www.example.com
// @version             3
// @require             http://openuserjs.org/src/libs/TimidScript/TSL_-_GM_Update.js
// @icon                http://i.imgur.com/FD46Ak3.png?1
// @include             *//www.example.com*
// @include             *//example.com*
// @grant               GM_xmlhttpRequest
// @grant               GM_info
// @grant               GM_getMetadata
// @grant               GM_getValue
// @grant               GM_setValue
// @grant               GM_deleteValue
// @grant               GM_registerMenuCommand
// @homeurl             https://openuserjs.org/scripts/TimidScript/GM_update_Tester
// ==/UserScript==

// @gm_update           manual
var notice = document.createElement("div");
notice.setAttribute("style", "position: fixed; top: 10px; right: 10px; width: 400px; color: green; background-color: #E7E7F1; z-index: 999999999999; padding: 10px; border: 3px solid pink; margin: 0; text-align: center;");
notice.innerHTML = "Click the button below to do a manual check using <a href='https://greasyfork.org/scripts/4439'>"
    + "GM_update Tester's meta.js</a> file hosted on Greasy Fork. The result is printed in the console."
    + "Or you can select the GreaseMonkey menu command to do an update check from "
    + "<a href='https://openuserjs.org/scripts/TimidScript/GM_update_Tester'> OpenUserJS homepage.";

document.body.appendChild(notice);

var btn = document.createElement("div");
btn.setAttribute("style", "margin: 5px; padding:5px; text-align: center; border: 1px red solid; background-color: #FBF8C8; color: red;  border-radius: 5px; width: 380px; cursor: pointer;");
btn.textContent = "Console Print Online Version";
btn.onclick = WhyClick;
notice.appendChild(btn);


function WhyClick()
{
    try
    {
        console.log(GM_update)
    }
    catch (e) { console.warn(e); }

    var url = "https://greasyfork.org/scripts/4439/code/4439.meta.js";
    GM_update.isThereANewVersion(url, updateCallback);
}

function updateCallback(success)
{
    console.log("Has new version check succeeded: ", success);
    if (success)
    {
        console.info("Do Version Match: ", GM_update.online.version == GM_update.installed.version);
        console.log(GM_update.online);
        console.log(GM_update.installed);
    }
}