Get of extension from Chrome-WebStore [chrome.google.com]

Add button for get .crx of extension or theme from Chrome-WebStore

  1. // ==UserScript==
  2. // @name Get of extension from Chrome-WebStore [chrome.google.com]
  3. // @version 0.2
  4. // @description Add button for get .crx of extension or theme from Chrome-WebStore
  5. // @description Bookmartklet version: http://bit.ly/get_crx_chrome_bookmarklet
  6. // @author Vyacheslav Vasiliev
  7. // @include *chrome.google.com/webstore/*
  8. // @namespace 132-148-320
  9. // @copyright © 2017, Vyacheslav Vasiliev (vyach.vasiliev\аt\gmail\dоt\com)
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13.  
  14. (function () {
  15. var install_button = document.querySelector('[role="dialog"] div[role="button"][aria-label]');
  16. if (install_button) {
  17. var install_button_classes = install_button.className;
  18. var get_crx_button = document.createElement('a');
  19. get_crx_button.className = install_button_classes;
  20. get_crx_button = install_button.parentNode.insertBefore(get_crx_button, install_button);
  21. get_crx_button.innerText = "Get .crx file";
  22. get_crx_button.id = 'get-crx-file';
  23. var crx_param = getCRXParam();
  24. var crx_name = crx_param[0];
  25. var crx_url_download = crx_param[1];
  26. get_crx_button.setAttribute('download', crx_name+'.crx');
  27. get_crx_button.setAttribute('href', crx_url_download);
  28.  
  29. // add style for button
  30. var get_crx_button_style = '#get-crx-file {margin-right:2px; } #get-crx-file:hover {opacity:0.8; }';
  31. addStyle(get_crx_button_style);
  32. // if not added style
  33. get_crx_button.style.marginRight = "2px";
  34. }
  35. function getCRXParam() {
  36. // console.info('press getCRX');
  37. var crx_url_download = 'https://clients2.google.com/service/update2/crx?response=redirect&prodversion=49.0&x=id%3D%ID_EXTENSION%%26installsource%3Dondemand%26uc';
  38. var id_extension = window.location.pathname.split('/').slice(-1);
  39. if (id_extension) {
  40. crx_url_download = crx_url_download.replace('%ID_EXTENSION%', id_extension);
  41. // console.info('Build get .crx of url: %s', crx_url_download);
  42. }
  43. var crx_name = document.title.split('-')[0].trim();
  44. if(!crx_name) crx_name = id_extension;
  45. return [crx_name, crx_url_download];
  46. }
  47. function addStyle(css) {
  48. var style = document.createElement('style');
  49. style.type = 'text/css';
  50. if (style.styleSheet) {
  51. style.styleSheet.cssText = css;
  52. } else {
  53. style.appendChild(document.createTextNode(css));
  54. }
  55. }
  56. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址