Skip to content

Instantly share code, notes, and snippets.

@b2ox
Created May 26, 2019 07:41
Show Gist options
  • Save b2ox/dd25054bf922173f7855386545e4ea7a to your computer and use it in GitHub Desktop.
Save b2ox/dd25054bf922173f7855386545e4ea7a to your computer and use it in GitHub Desktop.
Pixivのブックマーク編集ページで"あなたのブックマークタグ"の並びを"名前順↑"にする
// ==UserScript==
// @name Pixiv fix bookmark-tag sort
// @namespace https://www.pixiv.net/
// @version 0.1
// @description ブックマークタグの並びを名前順↑にする
// @author b2ox
// @match https://www.pixiv.net/bookmark_add.php*
// @grant none
// ==/UserScript==
'use strict';
const sleep = msec => new Promise(resolve => setTimeout(resolve, msec));
const waitCond = async (mes, timeOut, f) => {
console.log(`wait ${mes}...`);
timeOut *= 1000;
const n = Date.now();
while (Date.now() - n < timeOut) {
if (f()) return true;
await sleep(100);
}
console.log(`wait ${mes} timeout.`);
return false;
}
(async () => {
const sn = '._clickable:contains("名前順")';
if (!await waitCond('tag-sort', 10, () => $(sn).length > 0)) return;
const e = $(sn);
if (e.text() == '名前順') e.trigger('click').trigger('click');
else if (e.text() == '名前順↓') e.trigger('click');
console.log('sort: 名前順↑');
})();
@b2ox
Copy link
Author

b2ox commented May 26, 2019

久々にPixivのタグ編集したらブックマークタグのデフォルトソートが件数になってる上に設定を覚えてくれないクソ仕様になりはてていたので、
Tampermonkeyで名前順↑に変えるスクリプトを書いた。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment