Pixiv Replace With Original

Replace Pixiv image with original image

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Pixiv Replace With Original
// @name:zh-TW   Pixiv 替換為高畫質原圖
// @name:zh-CN   Pixiv 替换为高画质原图
// @namespace    https://blog.maple3142.net/
// @version      0.4
// @description  Replace Pixiv image with original image
// @description:zh-TW  替換 Pixiv 的圖片為高畫質原圖
// @description:zh-CN  替换 Pixiv 的图片为高画质原图
// @author       maple3142
// @match        https://www.pixiv.net/member_illust.php?mode=medium&illust_id=*
// @match        https://www.pixiv.net/member_illust.php?illust_id=*&mode=medium
// @compatible   firefox >=52
// @compatible   chrome >=55
// ==/UserScript==

;(function() {
	'use strict'
	const $ = s => document.querySelector(s)
	const $$ = s => [...document.querySelectorAll(s)]
	function onDomChange(cb) {
		new MutationObserver(() => setTimeout(cb, 50)).observe(document.body, { childList: true })
	}
	function replaceImage() {
		const els = $$('div[role=presentation]>a')
		for (const a of els) {
			const image = a.querySelector('img')
			image.src = a.href
			image.srcset = ''
		}
	}
	onDomChange(replaceImage)
})()