NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name 豆包无水印原图下载@公众号:代码简单说 // @namespace http://tampermonkey.net/ // @version 1.0.1 // @description 在页面右上角添加按钮,下载指定img标签的图片 // @author 公众号:代码简单说 // @match https://www.doubao.com/chat/* // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; // 创建按钮 const btn = document.createElement('button'); btn.innerText = '下载原图'; btn.style.position = 'fixed'; btn.style.top = '10px'; btn.style.right = '60px'; btn.style.zIndex = 9999; btn.style.padding = '10px 40px'; btn.className="semi-button semi-button-primary samantha-button-DHlMIF secondary-RcjOde medium-_9OY57 h-36 px-20 !rounded-12 s-font-xs-strong !text-white"; btn.onclick = async () => { const img = document.querySelector(`div[data-visible=true] img[data-testid="in_painting_picture"`) if (!img) { alert('找不到图片元素!'); return; } const imgUrl = img.src; const fileName = imgUrl.split('/').pop().split('?')[0] || 'image.jpg'; try { const res = await fetch(imgUrl, { mode: 'cors' }); const blob = await res.blob(); const blobUrl = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = blobUrl; a.download = fileName; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(blobUrl); // 释放内存 } catch (err) { alert('下载失败:' + err.message); } }; window.addEventListener('load', () => { document.body.appendChild(btn); }); })();