i.pximg.net 403 Forbidden Fix

Fix Pixiv raw image 403

安装此脚本
作者推荐脚本

您可能也喜欢Pixiv 替换为高画质原图

安装此脚本
  1. // ==UserScript==
  2. // @name i.pximg.net 403 Forbidden Fix
  3. // @namespace https://blog.maple3142.net/
  4. // @version 0.3
  5. // @description Fix Pixiv raw image 403
  6. // @author maple3142
  7. // @match https://i.pximg.net/*
  8. // @match https://img-comic.pximg.net/*
  9. // @grant GM_xmlhttpRequest
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @compatible firefox >=52
  13. // @compatible chrome >=55
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. ;(function() {
  18. 'use strict'
  19. const params = new URLSearchParams(location.search)
  20. const removeAllChild = el => {
  21. while (el.firstChild) el.removeChild(el.firstChild)
  22. }
  23. function download(url, name = true) {
  24. const a = document.createElement('a')
  25. a.href = url
  26. a.download = name
  27. document.body.appendChild(a)
  28. a.click()
  29. a.remove()
  30. }
  31. if (document.title === '403 Forbidden') {
  32. const fname = location.pathname.split('/').slice(-1)[0]
  33.  
  34. removeAllChild(document.body)
  35. document.title = 'Loading image...'
  36. document.body.style.textAlign = 'center'
  37. const msg = document.createElement('h1')
  38. msg.textContent = 'Loading'
  39. msg.style.padding = '0px'
  40. msg.style.margin = '0px'
  41. document.body.appendChild(msg)
  42. const origlink = document.createElement('a')
  43. origlink.textContent = 'Original Link'
  44. origlink.href = `https://www.pixiv.net/member_illust.php?mode=medium&illust_id=${
  45. /(\d+)/.exec(fname)[1]
  46. }`
  47. origlink.target = '_blank'
  48. origlink.style.display = 'block'
  49. origlink.style.padding = '0px'
  50. origlink.style.margin = '0px'
  51. document.body.appendChild(origlink)
  52. GM_xmlhttpRequest({
  53. method: 'GET',
  54. url: location.href,
  55. headers: {
  56. Referer: `https://www.pixiv.net/`
  57. },
  58. responseType: 'blob',
  59. onload: xhr => {
  60. const blob = xhr.response
  61. const url = URL.createObjectURL(blob)
  62. const img = new Image()
  63. img.src = url
  64. msg.replaceWith(img)
  65. img.oncontextmenu = e => {
  66. e.preventDefault()
  67. if (confirm('Download Image?')) {
  68. download(url, fname)
  69. }
  70. }
  71. document.title = fname
  72. },
  73. onerror: e => {
  74. msg.textContent = 'Load failed.'
  75. }
  76. })
  77. }
  78. })()