Add-ons Manager - Scriptish Screenshot

[Scriptish only] Show screenshot on Scriptish user script page in Add-ons Manager.

当前为 2014-03-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @id addons-manager-scriptish-screenshot@loucypher
  3. // @name Add-ons Manager - Scriptish Screenshot
  4. // @namespace https://github.com/LouCypher/userscripts
  5. // @description [Scriptish only] Show screenshot on Scriptish user script page in Add-ons Manager.
  6. // @version 1.0
  7. // @author LouCypher
  8. // @license MPL 2.0
  9. // @icon https://addons.cdn.mozilla.net/media/img/addon-icons/default-32.png
  10. // @icon64URL https://addons.cdn.mozilla.net/media/img/addon-icons/default-64.png
  11. // @contributionURL http://loucypher.github.io/userscripts/donate.html?Add-ons+Manager+-+Scriptish+Screenshot
  12. // @homepageURL https://greasyfork.org/scripts/183
  13. // @supportURL https://greasyfork.org/scripts/183/feedback
  14. // @screenshot https://raw.github.com/LouCypher/userscripts/master/scriptish/addons-manager-scriptish-screenshot/screenshot.png
  15. // @resource CHANGELOG https://raw.github.com/LouCypher/userscripts/master/scriptish/addons-manager-scriptish-screenshot/CHANGELOG.txt
  16. // @resource LICENSE https://raw.github.com/LouCypher/userscripts/master/licenses/MPL/LICENSE.txt
  17. // @run-at document-start
  18. // @include about:addons
  19. // @include chrome://mozapps/content/extensions/extensions.xul
  20. // ==/UserScript==
  21. /* This Source Code Form is subject to the terms of the Mozilla Public
  22. * License, v. 2.0. If a copy of the MPL was not distributed with this
  23. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  24.  
  25.  
  26.  
  27. function getXPCOMInterface(aClass, aInterface) {
  28. return Components.classes["@mozilla.org/" + aClass].
  29. getService(Components.interfaces[aInterface]);
  30. }
  31.  
  32. const iOService = getXPCOMInterface("network/io-service;1", "nsIIOService");
  33. const styleSheetService= getXPCOMInterface("content/style-sheet-service;1",
  34. "nsIStyleSheetService");
  35.  
  36. let css = "/* Add-ons Manager Scriptish Screenshot\n\
  37. by LouCypher */\n\n\
  38. @namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);\
  39. \n@-moz-document url(about:addons),\
  40. \n url(chrome://mozapps/content/extensions/extensions.xul){\
  41. \n #detail-view[type=userscript] #detail-screenshot[width=null][height=null]{\
  42. \n min-width: 200px;\n min-height: 150px;\n }\n}\n";
  43.  
  44. let uri = iOService.newURI("data:text/css," + encodeURIComponent(css), null, null);
  45. styleSheetService.loadAndRegisterSheet(uri, styleSheetService.AGENT_SHEET);
  46.  
  47. window.addEventListener("unload", function() {
  48. styleSheetService.unregisterSheet(uri, styleSheetService.AGENT_SHEET);
  49. });