Greasy Fork

来自缓存

Greasy Fork is available in English.

Wandoujia-IconDownloader

用来在 豌豆荚 下载应用图标的脚本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Wandoujia-IconDownloader
// @namespace    https://github.com/FotixChiang
// @version      0.0.1
// @description  用来在 豌豆荚 下载应用图标的脚本
// @author       Money
// @match        https://www.wandoujia.com/apps/*
// @contents     *://*.25pp.com
// @grant        none
// @license      MIT License
// @run-at       document-end
// ==/UserScript==

(function() {
  // Your code here...
  var a = document.createElement('a');
  a.innerHTML = '下载图标';
  // 增加内容
  // 增加样式
  a.className = 'download install-btn'
  a.href = 'javascript:;';
  a.download = document.getElementsByClassName("title")[0].innerText;
  a.click();
   var doDownload = function(blob, filename) {
     var a = document.createElement('a');
     a.download = filename;
     a.href = blob;
     a.click();
}
  var container = document.getElementsByClassName("download-wp")[0];
  container.appendChild(a,container.childNodes[0]);

  a.addEventListener('click', function (ev) {
  var blob = document.getElementsByClassName("app-icon")[0].childNodes[1].getAttribute('src');
  var filename = document.getElementsByClassName("title")[0].innerText;
  download(blob,filename);
});

   var download = function (url, filename) {
   if (!filename) filename = url.split('\\').pop().split('/').pop();
   fetch(url, {
      headers: new Headers({
        'Origin': location.origin
    }),
     mode: 'cors'
   })
  .then(response => response.blob())
  .then(blob => {
    let blobUrl = window.URL.createObjectURL(blob);
    doDownload(blobUrl, filename);
  })
  .catch(e => {console.error(e); return false;});

  return true;
}
   
})();