From 63dabdcc7f17e153b541bd357a4f0c72a59551cc Mon Sep 17 00:00:00 2001 From: hdk5 Date: Mon, 1 Jan 2024 17:04:15 +0200 Subject: [PATCH 1/2] Add ci-en --- translate-pixiv-tags.user.js | 85 ++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/translate-pixiv-tags.user.js b/translate-pixiv-tags.user.js index c769563..28f28c5 100644 --- a/translate-pixiv-tags.user.js +++ b/translate-pixiv-tags.user.js @@ -28,6 +28,8 @@ // @match *://misskey.design/* // @match *://skeb.jp/* // @match *://fantia.jp/* +// @match *://ci-en.net/* +// @match *://ci-en.dlsite.com/* // @grant GM_getResourceText // @grant GM_getResourceURL // @grant GM_xmlhttpRequest @@ -83,6 +85,7 @@ // @resource cafe24-logo https://raw.githubusercontent.com/danbooru/danbooru/e2edff29d5c23bfdf0c6852ed8c195e1b70e08a4/public/images/cafe24-logo.png // @resource carrd-logo https://raw.githubusercontent.com/danbooru/danbooru/e2edff29d5c23bfdf0c6852ed8c195e1b70e08a4/public/images/carrd-logo.png // @resource catbox-logo https://raw.githubusercontent.com/danbooru/danbooru/e2edff29d5c23bfdf0c6852ed8c195e1b70e08a4/public/images/catbox-logo.png +// @resource ci-en-logo https://raw.githubusercontent.com/danbooru/danbooru/a6be8ff21cbceb7a1ce12534c0f9a6c4695e0178/public/images/ci-en-logo.png // @resource circle.ms-logo https://raw.githubusercontent.com/danbooru/danbooru/e2edff29d5c23bfdf0c6852ed8c195e1b70e08a4/public/images/circle.ms-logo.png // @resource class101-logo https://raw.githubusercontent.com/danbooru/danbooru/e2edff29d5c23bfdf0c6852ed8c195e1b70e08a4/public/images/class101-logo.png // @resource clip-studio-logo https://raw.githubusercontent.com/danbooru/danbooru/e2edff29d5c23bfdf0c6852ed8c195e1b70e08a4/public/images/clip-studio-logo.png @@ -1006,6 +1009,7 @@ const SITE_ORDER = [ "Booth", "Deviant Art", "Fantia", + "Ci-En", "Foundation", "Furaffinity", "Hentai Foundry", @@ -1070,6 +1074,7 @@ const SITE_RULES = [ { name: "ArtStation", domain: "artstation.com" }, { name: "ArtStreet", domain: "medibang.com" }, { name: "Bilibili", domain: "bilibili.com" }, + { name: "Ci-En", domain: "ci-en.net" }, { name: "Deviant Art", domain: "deviantart.com" }, { name: "Deviant Art", domain: "fav.me" }, { name: "Deviant Art", domain: "sta.sh" }, @@ -1597,6 +1602,9 @@ const NORMALIZE_PROFILE_URL = { "skeb.jp": { path: /^\/@\w+$/, }, + "ci-en.net": { + path: /^\/creator\/\d+$/, + }, }; /** @@ -4274,6 +4282,81 @@ function initializeSkeb () { }); } +function initializeCiEn () { + const toProfileUrl = (el) => `https://ci-en.net/creator/${safeMatchMemoized(el.href, /\/creator\/(\d+)/, 1)}`; + + // Artist name + // In profile: https://ci-en.dlsite.com/creator/4126 + // In article: https://ci-en.dlsite.com/creator/4126/article/1035340 + findAndTranslate("artist", "a", { + asyncMode: true, + predicate: ".c-grid-account-name .e-title > a", + toProfileUrl, + tagPosition: TAG_POSITIONS.afterend, + classes: "inline", + ruleName: "artist profile", + }); + + // Artist in article card by followed artists + // https://ci-en.dlsite.com/mypage + findAndTranslate("artist", "a", { + asyncMode: true, + predicate: ".c-card-article .c-card-content .e-title > a", + toProfileUrl, + tagPosition: TAG_POSITIONS.afterParent, + ruleName: "artist article card", + }); + + // Artist in article card in ranking + // https://ci-en.dlsite.com/mypage + findAndTranslate("artist", "a", { + asyncMode: true, + predicate: ".c-card-article-ranking .c-card-article-ranking-name .l-media-content > a", + toProfileUrl, + tagPosition: TAG_POSITIONS.afterend, + ruleName: "artist article ranking card", + }); + + // Artist in artist card in artist recommendations + // https://ci-en.dlsite.com/mypage + findAndTranslate("artist", "a", { + asyncMode: true, + predicate: ".c-card-creator .c-card-header .e-title > a", + toProfileUrl, + tagPosition: TAG_POSITIONS.afterParent, + ruleName: "artist creator card", + }); + + // Artist in artist card in artist ranking + // https://ci-en.dlsite.com/mypage + // https://ci-en.dlsite.com/ranking/creators/daily?categoryId=1 + findAndTranslate("artist", "a", { + asyncMode: true, + predicate: ".c-card-creator-archives .c-card-creator-archives-name .e-title > a", + toProfileUrl, + tagPosition: TAG_POSITIONS.afterParent, + ruleName: "artist creator ranking card", + }); + + // Tags in article + // https://ci-en.dlsite.com/creator/4126/article/1035340 + findAndTranslate("tag", "a", { + asyncMode: true, + predicate: ".c-hashTagList .c-hashTagList-item > a", + tagPosition: TAG_POSITIONS.beforeend, + ruleName: "tag article", + }); + + // Tags in sidebar + // https://ci-en.dlsite.com/creator/4126/article/1035340 + findAndTranslate("tag", "a", { + asyncMode: true, + predicate: ".c-articleFilteringList .c-articleFilteringList-item > a", + tagPosition: TAG_POSITIONS.afterend, + ruleName: "tag sidebar", + }); +} + function initialize () { GM_jQuery_setup(); GM_addStyle(PROGRAM_CSS); @@ -4306,6 +4389,8 @@ function initialize () { case "misskey.design": initializeMisskey(); break; case "fantia.jp": initializeFantia(); break; case "skeb.jp": initializeSkeb(); break; + case "ci-en.net": + case "ci-en.dlsite.com": initializeCiEn(); break; default: if (window.location.host.endsWith("artstation.com")) { initializeArtStation(); From ad12b1b1bf76a5ae8fd674969e252deb3f17129c Mon Sep 17 00:00:00 2001 From: hdk5 Date: Sun, 4 Feb 2024 00:08:12 +0200 Subject: [PATCH 2/2] ci-en: fix linter errors --- translate-pixiv-tags.user.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/translate-pixiv-tags.user.js b/translate-pixiv-tags.user.js index 28f28c5..9b46b23 100644 --- a/translate-pixiv-tags.user.js +++ b/translate-pixiv-tags.user.js @@ -4283,7 +4283,10 @@ function initializeSkeb () { } function initializeCiEn () { - const toProfileUrl = (el) => `https://ci-en.net/creator/${safeMatchMemoized(el.href, /\/creator\/(\d+)/, 1)}`; + const getNormalizedUrl = (/** @type {HTMLElement} */ el) => { + const a = /** @type {HTMLAnchorElement} */(el); + return `https://ci-en.net/creator/${safeMatchMemoized(a.href, /\/creator\/(\d+)/, 1)}`; + }; // Artist name // In profile: https://ci-en.dlsite.com/creator/4126 @@ -4291,7 +4294,7 @@ function initializeCiEn () { findAndTranslate("artist", "a", { asyncMode: true, predicate: ".c-grid-account-name .e-title > a", - toProfileUrl, + toProfileUrl: getNormalizedUrl, tagPosition: TAG_POSITIONS.afterend, classes: "inline", ruleName: "artist profile", @@ -4302,7 +4305,7 @@ function initializeCiEn () { findAndTranslate("artist", "a", { asyncMode: true, predicate: ".c-card-article .c-card-content .e-title > a", - toProfileUrl, + toProfileUrl: getNormalizedUrl, tagPosition: TAG_POSITIONS.afterParent, ruleName: "artist article card", }); @@ -4312,7 +4315,7 @@ function initializeCiEn () { findAndTranslate("artist", "a", { asyncMode: true, predicate: ".c-card-article-ranking .c-card-article-ranking-name .l-media-content > a", - toProfileUrl, + toProfileUrl: getNormalizedUrl, tagPosition: TAG_POSITIONS.afterend, ruleName: "artist article ranking card", }); @@ -4322,7 +4325,7 @@ function initializeCiEn () { findAndTranslate("artist", "a", { asyncMode: true, predicate: ".c-card-creator .c-card-header .e-title > a", - toProfileUrl, + toProfileUrl: getNormalizedUrl, tagPosition: TAG_POSITIONS.afterParent, ruleName: "artist creator card", }); @@ -4333,7 +4336,7 @@ function initializeCiEn () { findAndTranslate("artist", "a", { asyncMode: true, predicate: ".c-card-creator-archives .c-card-creator-archives-name .e-title > a", - toProfileUrl, + toProfileUrl: getNormalizedUrl, tagPosition: TAG_POSITIONS.afterParent, ruleName: "artist creator ranking card", });