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. It now should support other browsers beside FireFox, like Chrome and Opera.

目前为 2014-10-31 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GM_update Tester
  3. // @namespace TimidScript
  4. // @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. It now should support other browsers beside FireFox, like Chrome and Opera.
  5. // @include www.example.com
  6. // @version 1.0.1b
  7. // @require http://openuserjs.org/src/libs/TimidScript/TSL_-_GM_Update.js
  8. // @icon https://i.imgur.com/FD46Ak3.png
  9. // @include *//www.example.com*
  10. // @include *//example.com*
  11. // @grant GM_xmlhttpRequest
  12. // @grant GM_info
  13. // @grant GM_getMetadata
  14. // @grant GM_getValue
  15. // @grant GM_setValue
  16. // @grant GM_deleteValue
  17. // @grant GM_registerMenuCommand
  18. // @homeurl https://openuserjs.org/scripts/TimidScript/GM_update_Tester
  19. // ==/UserScript==
  20.  
  21. // @gm_update manual
  22. var notice = document.createElement("div");
  23. 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;");
  24. notice.innerHTML = "Click the button below to do a manual check using <a href='https://greasyfork.org/scripts/4439'>"
  25. + "GM_update Tester's meta.js</a> file hosted on Greasy Fork. The result is printed in the console."
  26. + "Or you can select the GreaseMonkey menu command to do an update check from "
  27. + "<a href='https://openuserjs.org/scripts/TimidScript/GM_update_Tester'> OpenUserJS homepage.";
  28.  
  29. document.body.appendChild(notice);
  30.  
  31. var btn = document.createElement("div");
  32. 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;");
  33. btn.textContent = "Console Print Online Version";
  34. btn.onclick = WhyClick;
  35. notice.appendChild(btn);
  36.  
  37.  
  38. function WhyClick()
  39. {
  40. try
  41. {
  42. console.log(GM_update)
  43. }
  44. catch (e) { console.warn(e); }
  45.  
  46. var url = "https://greasyfork.org/scripts/4439/code/4439.meta.js";
  47. GM_update.isThereANewVersion(url, updateCallback);
  48. }
  49.  
  50. function updateCallback(success)
  51. {
  52. console.log("Has new version check succeeded: ", success);
  53. if (success)
  54. {
  55. console.info("Do Version Match: ", GM_update.online.version == GM_update.installed.version);
  56. console.log(GM_update.online);
  57. console.log(GM_update.installed);
  58. }
  59. }