// ==UserScript== // @name 图片下载器 // @name:en Image downloader // @namespace http://tampermonkey.net/ // @description 某些网站图片,右键不能保存,使用此脚本,提取后可直接右键保存,如千库网、B战封面、淘宝天猫等网站。点击右键后,即可看到图片下载选项。 // @description:en It can extract the images of most websites, such as qianku.com, baotu.com, huaban.com, and the video cover of YouTube / BiliBili. Right click to see the image extraction options // @version 1.2 // @author 桃源隐叟 // @include * // @grant GM_openInTab // @grant GM_download // @run-at context-menu // @match * // @match https://www.bilibili.com/ // @match https://588ku.com/ // @homepageURL https://github.com/taoyuancun123/modifyText/blob/master/modifyText.js // @supportURL https://greasyfork.org/zh-CN/scripts/419894/feedback // @downloadURL none // ==/UserScript== (function () { 'use strict'; try{ document.querySelector(".tyc-image-container").remove(); }catch{ } let imgUrls = []; let bodyStr = document.body.innerHTML; try { let imgEles = document.getElementsByTagName("img") for (let i = 0; i < imgEles.length; i++) { //console.log(imgEles[i].src); if (!imgUrls.includes(imgEles[i].src)) { imgUrls.push(imgEles[i].src); } } } catch { //alert("error"); } try { let imgRegs = bodyStr.match(/(?<=background-image:\s*url\()(\S+)(?=\))/g); for (let i = 0; i < imgRegs.length; i++) { //console.log(imgRegs[i]); if (!imgUrls.includes(imgRegs[i].replace(/"/g, ""))) { imgUrls.push(imgRegs[i].replace(/"/g, "")); } } } catch { //alert("error"); } let imgContainer = `
${naturalW}X${naturalH}
`; document.querySelector(`.tyc-img-item-container-${index}`).insertAdjacentHTML("beforeend", imgInfo); //console.log(img); }); document.body.onclick=(e)=>{ if(e.target.nodeName=="IMG" && e.target.className==="tyc-image-preview"){ try{ document.querySelector(".show-big-image").remove(); } catch{ } document.body.insertAdjacentHTML("beforeend",showBigImage); let showItem=`