// ==UserScript== // @name Convert WebP to JPG & Automatically Downloading the photos in WeChat Official Account Articles // @author Lepturus // @description 微信公众号文章webp图片格式转换为jpg, 添加ON/OFF按钮可选择是否浏览时自动下载图片, 并额外支持豆瓣站点webp转jpg。 // @include *://mp.weixin.qq.com/* // @include *://mmbiz.qpic.cn/* // @include *://doubanio.com/* // @include *://www.douban.com/* // @grant GM_addStyle // @version 1.2 // @namespace https://greasyfork.org/users/213516 // @downloadURL none // ==/UserScript== GM_addStyle(".switch{position:relative;width:45px;height:17px;margin-bottom:-2px;display:inline-block} .switch input{display:none}.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ca2222;transition:.4s}.slider:before{position:absolute;content:'';height:13px;width:13px;left:2px;bottom:2px;background-color:#fff;transition:.4s}input:checked+.slider{background-color:#2ab934}input:checked+.slider:before{transform:translateX(28px)}.on{display:none}.off,.on{color:#fff;position:absolute;transform:translate(-50%,-50%);top:50%;left:50%;font-size:8px}input:checked+.slider .on{display:block} input:checked+.slider .off{display:none}.slider.round{border-radius:17px}.slider.round:before{border-radius:50%}") var imgs = document.getElementsByTagName("img") // 微信公众号文章批量下载按钮 if(document.getElementById('meta_content')){ var dswitch = document.createElement ('label'); dswitch.innerHTML = "
ONOFF
"; dswitch.setAttribute('class', 'switch'); document.getElementById('meta_content').appendChild(dswitch);} function downloadImg(url, name) { fetch(url).then(res => res.blob()).then((blob) => { const a = document.createElement('a'); a.style.display = 'none'; a.href = URL.createObjectURL(blob); a.download = name; document.body.appendChild(a); a.click(); document.body.removeChild(a); }); } function convert(){ for (var i=0;i