Greasy Fork 还支持 简体中文。

Cracking SVG Downloading

Cracking SVG Downloading. Click the SVG icon after login to download the SVG file for free.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Cracking SVG Downloading
// @namespace    http://tampermonkey.net/
// @version      2024-03-20
// @description  Cracking SVG Downloading. Click the SVG icon after login to download the SVG file for free.
// @author       yusanshi
// @match        https://www.flaticon.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=flaticon.com
// @require      https://cdn.jsdelivr.net/npm/[email protected]/minified/arrive.min.js
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';

  document.arrive('#download-free', function () {
    this.click();
  });

  document.arrive('#download > a.btn-svg', { existing: true }, function () {
    this.querySelector('i').remove();
    this.addEventListener('click', async () => {
      const imageId = window.location.pathname.split('_').at(-1);
      const data = await fetch(
        `https://www.flaticon.com/editor/icon/svg/${imageId}?type=standard`
      ).then((e) => e.json());

      // https://stackoverflow.com/questions/3749231/download-file-using-javascript-jquery
      fetch(data.url)
        .then((resp) => resp.blob())
        .then((blob) => {
          const url = window.URL.createObjectURL(blob);
          const a = document.createElement('a');
          a.style.display = 'none';
          a.href = url;
          a.download = `${window.location.pathname.split('/').at(-1)}.svg`;
          document.body.appendChild(a);
          a.click();
          window.URL.revokeObjectURL(url);
        });
    });
  });
})();