Greasy Fork

Greasy Fork is available in English.

微信读书图片复制和下载

为了方便在微信读书看技术书复制图片用的,点击按钮新标签页打开图片的功能,还有图片下载的功能,图片下载的名称是按照时间戳为图片名的。

当前为 2024-03-05 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         微信读书图片复制和下载
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  为了方便在微信读书看技术书复制图片用的,点击按钮新标签页打开图片的功能,还有图片下载的功能,图片下载的名称是按照时间戳为图片名的。
// @author       ldbmcs
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @match        https://weread.qq.com/web/reader*
// @grant        unsafeWindow
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_openInTab
// @grant        GM_download
// @grant        GM_setClipboard
// @grant        GM_notification

// ==/UserScript==

(function() {
    'use strict';

    // 当DOM完全加载后执行
    window.addEventListener('load', function() {
        // 查找所有具有特定类名的img元素
        const images = document.querySelectorAll('img.wr_readerImage_opacity');
        
        images.forEach(function(img) {
            // 为每个找到的img元素添加下载链接
            const downloadLink = document.createElement('a');
            downloadLink.setAttribute('href', img.src);
            downloadLink.setAttribute('download', 'download');
            downloadLink.innerText = '下载';
            downloadLink.style.position = 'absolute';
            downloadLink.style.top = '5px';
            downloadLink.style.left = '5px';
            downloadLink.style.backgroundColor = 'white';
            downloadLink.style.color = 'black';
            downloadLink.style.padding = '5px';
            downloadLink.style.borderRadius = '5px';
            downloadLink.style.textDecoration = 'none';
            
            // 将下载链接添加到图片的父元素,假设父元素支持相对定位
            img.parentNode.style.position = 'relative';
            img.parentNode.appendChild(downloadLink);
        });
    });
})();