Last active
March 22, 2023 16:31
-
-
Save whiteball/c37e0f01884341bec6da77b054b9df22 to your computer and use it in GitHub Desktop.
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 AIのべりすと ローカルに存在しないリモートデータにNEWと表示 | |
// @namespace https://ai-novelist-share.geo.jp/ | |
// @version 0.1.0 | |
// @description AIのべりすと作品リスト(リモート)で、ローカルに存在しないIDを持った作品のタイトルの先頭に🆕を追加します。 | |
// @author しらたま | |
// @match https://ai-novel.com/works.php | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=ai-novel.com | |
// @updateURL https://gist.github.com/whiteball/c37e0f01884341bec6da77b054b9df22/raw/ai_novelist_mark_new_for_remote.user.js | |
// @downloadURL https://gist.github.com/whiteball/c37e0f01884341bec6da77b054b9df22/raw/ai_novelist_mark_new_for_remote.user.js | |
// @supportURL https://gist.github.com/whiteball/c37e0f01884341bec6da77b054b9df22 | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const ids = new Set() | |
for (const key of Object.keys(localStorage)) { | |
if (key.indexOf('works') !== 0) { | |
continue | |
} | |
const work_id = Number(key.slice('works'.length)) | |
if (isNaN(work_id)) { | |
continue | |
} | |
ids.add(work_id) | |
} | |
const refreshlist_remote_orig = window.refreshlist_remote | |
window.refreshlist_remote = function (iterpos = 0, force_refresh = false) { | |
refreshlist_remote_orig(iterpos, force_refresh) | |
let type = 1 | |
const works_perf_json = window.jQuery.cookie('works_perf') | |
if (works_perf_json) { | |
const works_perf = JSON.parse(JSON.parse(decodeURI(works_perf_json))) | |
if (works_perf.style) { | |
type = Number(works_perf.style) | |
} | |
} | |
let query = '#works_section_up .btn-square' | |
switch(type) { | |
case 2: | |
query = '#works_remote_left_short .btn-square' | |
break | |
case 3: | |
query = '.works_item_adjustment .works_title' | |
break | |
case 1: | |
default: | |
// query = '#works_section_up .btn-square' | |
break | |
} | |
for (const elem of document.querySelectorAll(query)) { | |
let target = elem.parentElement.parentElement.parentElement | |
if (type !== 3) { | |
target = target.parentElement | |
} | |
if (target && target.id.indexOf('works_section_remote') === 0) { | |
const target_id = Number(target.id.slice('works_section_remote'.length)) | |
if (isNaN(target_id) || ! ids.has(target_id)) { | |
if (elem.value) { | |
elem.value = '🆕' + elem.value | |
} else { | |
elem.innerText = '🆕' + elem.innerText | |
} | |
} | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment