From 24553a45afe09fdff50b14ddeed9fb4b35cf55b9 Mon Sep 17 00:00:00 2001 From: skscript Date: Sat, 28 Oct 2023 13:13:16 +0900 Subject: [PATCH] =?UTF-8?q?pef.user.js=20=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pef.user.js | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 pef.user.js diff --git a/pef.user.js b/pef.user.js new file mode 100644 index 0000000..55790cf --- /dev/null +++ b/pef.user.js @@ -0,0 +1,62 @@ +// ==UserScript== +// @name PixivフォローユーザーURL抽出&次ページ +// @namespace https://greasyfork.org/ja/users/1126644-s-k-script +// @version 0.1.4 +// @description Pixivのフォローページから各ユーザーのURLを抽出しクリップボードへコピーし、次のページに進む +// @author S.K.Script +// @homepage https://greasyfork.org/ja/users/1126644-s-k-script +// @updateURL https://greasyfork.org/scripts/470826-pixiv%E3%83%95%E3%82%A9%E3%83%AD%E3%83%BC%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BCurl%E6%8A%BD%E5%87%BA-%E6%AC%A1%E3%83%9A%E3%83%BC%E3%82%B8/code/Pixiv%E3%83%95%E3%82%A9%E3%83%AD%E3%83%BC%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BCURL%E6%8A%BD%E5%87%BA%EF%BC%86%E6%AC%A1%E3%83%9A%E3%83%BC%E3%82%B8.user.js +// @license GPL-3.0-only +// @match https://www.pixiv.net/users/*/following* +// @icon https://www.google.com/s2/favicons?sz=64&domain=pixiv.net +// @run-at context-menu +// @grant GM.setClipboard + +// ==/UserScript== + +(function() { + 'use strict'; + + // Your code here... + function extractUrls() { + let urls = new Set(); + const elements = document.querySelectorAll("section div:nth-child(2) > div a[href^='/users/']"); + elements.forEach(element => { + const href = element.href; + if (!href.endsWith("/request")) { + urls.add(href); + } + }); + return urls; + } + + const urls = extractUrls(); + console.log("urls", urls); + if(urls.size < 24) { + window.alert("[警告] 抽出されたURLは" + urls.size + "個であり、24個よりも少ないです。これは抽出ミスの可能性があります。その場合は本UserScriptの改修が必要です。"); + } + + function getNextButton() { + const svg = document.querySelector("nav > a:last-child > svg"); + if (!svg) { + return undefined; + } + return svg.parentElement; + } + + let str = ""; + for (const url of urls) { + str += url; + str += "\n"; + } + + GM.setClipboard(str); + + const nextBtn = getNextButton(); + if (!nextBtn) { + window.alert("抽出は終わりましたが、次ページボタンを見つけることができませんでした。そのため、次のページに移動することなくここで処理を終了します。"); + return; + } + nextBtn.click(); + +})(); \ No newline at end of file