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.0pre
  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. // @screenshot https://raw.github.com/LouCypher/userscripts/master/scriptish/addons-manager-scriptish-screenshot/screenshot.png
  13. // @resource CHANGELOG https://raw.github.com/LouCypher/userscripts/master/scriptish/addons-manager-scriptish-screenshot/CHANGELOG.txt
  14. // @resource LICENSE https://raw.github.com/LouCypher/userscripts/master/licenses/MPL/LICENSE.txt
  15. // @run-at document-start
  16. // @include about:addons
  17. // @include chrome://mozapps/content/extensions/extensions.xul
  18. // ==/UserScript==
  19. /* This Source Code Form is subject to the terms of the Mozilla Public
  20. * License, v. 2.0. If a copy of the MPL was not distributed with this
  21. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  22.  
  23.  
  24.  
  25. function getXPCOMInterface(aClass, aInterface) {
  26. return Components.classes["@mozilla.org/" + aClass].
  27. getService(Components.interfaces[aInterface]);
  28. }
  29.  
  30. const iOService = getXPCOMInterface("network/io-service;1", "nsIIOService");
  31. const styleSheetService= getXPCOMInterface("content/style-sheet-service;1",
  32. "nsIStyleSheetService");
  33.  
  34. let css = "/* Add-ons Manager Scriptish Screenshot\n\
  35. by LouCypher */\n\n\
  36. @namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);\
  37. \n@-moz-document url(about:addons),\
  38. \n url(chrome://mozapps/content/extensions/extensions.xul){\
  39. \n #detail-view[type=userscript] #detail-screenshot[width=null][height=null]{\
  40. \n min-width: 200px;\n min-height: 150px;\n }\n}\n";
  41.  
  42. let uri = iOService.newURI("data:text/css," + encodeURIComponent(css), null, null);
  43. styleSheetService.loadAndRegisterSheet(uri, styleSheetService.AGENT_SHEET);
  44.  
  45. window.addEventListener("unload", function() {
  46. styleSheetService.unregisterSheet(uri, styleSheetService.AGENT_SHEET);
  47. });