Last active
April 30, 2024 11:42
-
-
Save book000/0326c9b0635d99b7c4ab891ccb5e67be to your computer and use it in GitHub Desktop.
Replace square images displayed on pixiv.net with full-size images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name pixiv replace full image | |
// @namespace https://tomacheese.com | |
// @version 1.0.1 | |
// @description Replace square images displayed on pixiv.net with full-size images | |
// @author Tomachi | |
// @match https://www.pixiv.net/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=pixiv.net | |
// @updateURL https://gist.github.com/book000/0326c9b0635d99b7c4ab891ccb5e67be/raw/pixiv-full-image.user.js | |
// @downloadURL https://gist.github.com/book000/0326c9b0635d99b7c4ab891ccb5e67be/raw/pixiv-full-image.user.js | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setInterval(() => { | |
const regex = | |
/https:\/\/i\.pximg\.net\/c\/[a-z0-9_]+\/(?:custom-thumb|img-master)\/img\/([0-9\/]+)\/([0-9_p]+)_(?:custom|square)1200\.jpg/; | |
document.querySelectorAll('div[type="illust"] div.fxGVAF').forEach((div) => { | |
const img = div.querySelector('img'); | |
if(!img) return; | |
const match = regex.exec(img.src); | |
if (!match) { | |
console.log("no match", img.src); | |
return; | |
} | |
const newUrl = `https://i.pximg.net/c/600x1200_90/img-master/img/${match[1]}/${match[2]}_master1200.jpg`; | |
img.src = newUrl; | |
// remove fxGVAF class | |
div.classList.remove("fxGVAF"); | |
}); | |
}, 300) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment