CRX Downloader

Allows downloading .crx'es from Google's Chrome Web Store

目前為 2015-03-08 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name CRX Downloader
  3. // @namespace CRX_Downloader
  4. // @id CRX_Downloader
  5. // @description Allows downloading .crx'es from Google's Chrome Web Store
  6. // @version 0.1
  7. // @author KOLANICH
  8. // @copyright KOLANICH, 2015 (based on http://chrome-extension-downloader.com/how-does-it-work.php and https://github.com/doraemonsk8ers/CRX_Downloader)
  9. // @homepageURL https://github.com/KOLANICH/CRX_Downloader
  10. // @license Unlicensed
  11. // @contributionURL https://github.com/KOLANICH/CRX_Downloader/fork
  12. // @contributionAmount feel free to fork and contribute
  13. // @include https://chrome.google.com/webstore/detail/*/*
  14. // @noframes 1
  15. // @run-at window-load
  16. // @optimize 1
  17. // ==/UserScript==
  18.  
  19. /*This is free and unencumbered software released into the public domain.
  20.  
  21. Anyone is free to copy, modify, publish, use, compile, sell, or
  22. distribute this software, either in source code form or as a compiled
  23. binary, for any purpose, commercial or non-commercial, and by any
  24. means.
  25.  
  26. In jurisdictions that recognize copyright laws, the author or authors
  27. of this software dedicate any and all copyright interest in the
  28. software to the public domain. We make this dedication for the benefit
  29. of the public at large and to the detriment of our heirs and
  30. successors. We intend this dedication to be an overt act of
  31. relinquishment in perpetuity of all present and future rights to this
  32. software under copyright law.
  33.  
  34. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  35. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  36. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  37. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  38. OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  39. ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  40. OTHER DEALINGS IN THE SOFTWARE.
  41.  
  42. For more information, please refer to <http://unlicense.org/>*/
  43.  
  44. const downloadUriTemplate="https://clients2.google.com/service/update2/crx?response=redirect&prodversion=38.0&x=id%3D$ID$%26installsource%3Dondemand%26uc ";
  45. function parseAddonUri(path){
  46. let a=path.split("/");
  47. return {download:downloadUriTemplate.replace("$ID$",a[a.length-1]),id:a[a.length-2]};
  48. }
  49. function getButton(){
  50. return document.body.querySelector("div[role=button]");
  51. }
  52. function getFilename(){
  53. return getAddonName();
  54. }
  55. function getAddonName(){
  56. return document.getElementsByTagName("H1")[0].textContent
  57. }
  58. function replaceButton(){
  59. let parsed=parseAddonUri(window.location.pathname);
  60. let a=document.createElement("A");
  61. a.download=parsed.id+".crx";
  62. a.href=parsed.download;
  63. a.textContent="Download .CRX";
  64. let btn=getButton();
  65. a.className=btn.className;
  66. btn.parentNode.replaceChild(a,btn);
  67. }
  68. setTimeout(replaceButton,3000);