// ==UserScript== // @name Pixiv raw image 403 Forbidden Fix // @namespace https://blog.maple3142.net/ // @version 0.1 // @description Fix Pixiv raw image 403 // @author maple3142 // @match https://i.pximg.net/* // @grant GM_xmlhttpRequest // @grant GM_setValue // @grant GM_getValue // @downloadURL none // ==/UserScript== (function() { 'use strict' const params=new URLSearchParams(location.search) const removeAllChild=el=>{ while(el.firstChild)el.removeChild(el.firstChild) } function download(url,name=true){ const a=document.createElement('a') a.href=url a.download=name document.body.appendChild(a) a.click() a.remove() } if(document.title==='403 Forbidden'){ const fname=location.pathname.split('/').slice(-1)[0] GM_xmlhttpRequest({ method: 'GET', url: location.href, headers: { Referer: `https://www.pixiv.net/` }, responseType: 'blob', onload: xhr=>{ const blob=xhr.response const url=URL.createObjectURL(blob) const img=new Image() img.src=url removeAllChild(document.body) document.body.appendChild(img) img.oncontextmenu=e=>{ e.preventDefault() if(confirm('Download Image?')){ download(url,fname) } } }, onerror: console.error }) } })()