Greasy Fork

来自缓存

Greasy Fork is available in English.

米游社帖子图片链接提取

提取米游社帖子中的图片链接

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         米游社帖子图片链接提取
// @namespace    https://github.com/shangxueink
// @version      1.3
// @description  提取米游社帖子中的图片链接
// @author       shangxueink
// @match        https://www.miyoushe.com/*
// @license      MIT
// @grant        none
// @run-at       document-end
// @homepageURL  https://github.com/koakuuma/tampermonkey-scripts
// @supportURL   https://github.com/koakuuma/tampermonkey-scripts/issues
// ==/UserScript==
/******/ (() => { // webpackBootstrap
// 米游社帖子图片链接提取
// 提取米游社帖子中的图片链接

(function () {
  'use strict';

  function extractAndDownloadUrls() {
    // 更新选择器以匹配包含图片的元素
    const imgElements = document.querySelectorAll('div.mhy-img-article img');
    // 提取图片URL并移除查询字符串
    const urls = Array.from(imgElements).map(img => {
      const url = img.getAttribute('src');
      return url ? url.split('?')[0] : '';
    }).filter(url => url !== '');
    if (urls.length === 0) {
      alert('没有找到任何图片链接。');
      return;
    }
    if (confirm(`共找到了${urls.length}个图片链接,是否下载链接信息?`)) {
      downloadUrls(urls);
    }
  }
  function downloadUrls(urls) {
    const urlText = urls.join('\n');
    const blob = new Blob([urlText], {
      type: 'text/plain'
    });
    const href = URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = href;
    a.download = 'miyoushe_img_urls.txt';
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    URL.revokeObjectURL(href);
  }
  function createExtractButton() {
    const button = document.createElement('button');
    button.textContent = '提取图片链接';
    button.style.cssText = `
        position: fixed;
        top: 70px;
        left: 15%;
        transform: translateX(-50%);
        z-index: 1000;
        width: 120px;
        height: 60px;
        background-color: #53489c;
        color: white;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        font-size: 18px; 
        `;
    button.onclick = extractAndDownloadUrls;
    document.body.appendChild(button);
  }
  window.addEventListener('load', createExtractButton);
})();
/******/ })()
;