IconDownloader

用来在 Google Play 下载应用图标的脚本

当前为 2021-03-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IconDownloader
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.0.1
  5. // @description 用来在 Google Play 下载应用图标的脚本
  6. // @author Money
  7. // @match https://play.google.com/store/apps/details?id=*
  8. // @grant none
  9. // @license MIT License
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. // Your code here...
  15. var a = document.createElement('a');
  16. a.innerHTML = 'download';
  17. a.download = document.getElementsByClassName("AHFaub")[0].innerText;
  18. a.click();
  19. var doDownload = function(blob, filename) {
  20. var a = document.createElement('a');
  21. a.download = filename;
  22. a.href = blob;
  23. a.click();
  24. }
  25. var container = document.getElementsByClassName("hfWwZc")[0];
  26. container.insertBefore(a,container.childNodes[0]);
  27.  
  28. a.addEventListener('click', function (ev) {
  29. var blob = document.getElementsByClassName("xSyT2c")[0].childNodes[0].getAttribute('src').split("=s")[0]+"=s512-rw";
  30. var filename = document.getElementsByClassName("AHFaub")[0].innerText;
  31. download(blob,filename);
  32. });
  33.  
  34. var download = function (url, filename) {
  35. if (!filename) filename = url.split('\\').pop().split('/').pop();
  36. fetch(url, {
  37. headers: new Headers({
  38. 'Origin': location.origin
  39. }),
  40. mode: 'cors'
  41. })
  42. .then(response => response.blob())
  43. .then(blob => {
  44. let blobUrl = window.URL.createObjectURL(blob);
  45. doDownload(blobUrl, filename);
  46. })
  47. .catch(e => {console.error(e); return false;});
  48.  
  49. return true;
  50. }
  51.  
  52. })();