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.
目前為
// ==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);
}
}