Skip to content

Commit

Permalink
Merge branch 'PiFansubs' of https://github.com/Kuriel23/Presences int…
Browse files Browse the repository at this point in the history
…o PiFansubs
  • Loading branch information
Kuriel23 committed Jan 18, 2025
2 parents 406b0c2 + ce59ef3 commit 82010d0
Show file tree
Hide file tree
Showing 27 changed files with 677 additions and 403 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# ESLint is a tool for identifying and reporting on patterns
# found in ECMAScript/JavaScript code.
# More details at https://github.com/eslint/eslint
# and https://eslint.org

name: ESLint

on:
push:
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["main"]

jobs:
eslint:
name: Run eslint scanning
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install ESLint
run: |
npm install
npm install @microsoft/eslint-formatter-sarif@3.1.0
- name: Run ESLint
env:
SARIF_ESLINT_IGNORE_SUPPRESSED: "true"
run: npx eslint . --config .eslintrc.json --ext .js,.jsx,.ts,.tsx --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif
continue-on-error: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: eslint-results.sarif
wait-for-processing: true
7 changes: 6 additions & 1 deletion cli/bin/actions/modify.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions cli/src/actions/modify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ class Compiler {
from: resolve(this.cwd, "metadata.json"),
to: "metadata.json",
},
{
from: resolve(this.cwd, `${service}.json`),
to: `${service}.json`,
noErrorOnMissing: true,
},
],
}),
new webpack.WatchIgnorePlugin({
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "pmd -m",
"lint": "eslint --cache --fix . && prettier --cache --write .",
"lint:ci": "eslint --cache . && prettier --cache --check .",
"lint:ci": "prettier --cache --check .",
"format": "npm run metadataSorter && npm run lint",
"schemaEnforcer": "npm run format && npm run bumpChanged",
"compileTools": "tsc -p tools/tsconfig.json",
Expand Down Expand Up @@ -56,4 +56,4 @@
"pmd": "file:cli",
"prettier": "2.8.1"
}
}
}
18 changes: 12 additions & 6 deletions websites/A/AnimeLib/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,35 @@
"ru": "Смотрите аниме онлайн на русском"
},
"url": "anilib.me",
"version": "1.0.5",
"version": "1.0.7",
"logo": "https://cdn.rcd.gg/PreMiD/websites/A/AnimeLib/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/A/AnimeLib/assets/thumbnail.png",
"color": "#A020F0",
"category": "anime",
"tags": [
"anime",
"video",
"community"
"community",
"lib"
],
"iframe": true,
"iFrameRegExp": "kodik[.]info",
"settings": [
{
"id": "privacy",
"title": "Privacy Mode",
"icon": "fad fa-shield-alt",
"value": false
},
{
"id": "buttons",
"title": "Show Buttons",
"icon": "fas fa-compress-arrows-alt",
"value": true
},
{
"id": "privacy",
"title": "Privacy Mode",
"icon": "fad fa-user-secret",
"id": "titleAsPresence",
"title": "Show Anime Title As Presence",
"icon": "fad fa-user-edit",
"value": false
}
]
Expand Down
25 changes: 18 additions & 7 deletions websites/A/AnimeLib/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const isPrivacyMode = (setting: boolean, ageRestriction?: AgeRestriction) =>
cleanUrl = (location: Location) =>
location.href.replace(location.search, "").replace("/watch", "");

let iFrameVideo: IFrameVideo;
let iFrameVideo: IFrameVideo, currentDub: string;

presence.on("iFrameData", (data: IFrameVideo) => {
iFrameVideo = data;
Expand All @@ -51,9 +51,10 @@ presence.on("UpdateData", async () => {
largeImageText: "AnimeLib",
smallImageText: "AnimeLib",
},
[privacySetting, buttonsSetting] = await Promise.all([
[privacySetting, buttonsSetting, titleSetting] = await Promise.all([
presence.getSetting<boolean>("privacy"),
presence.getSetting<boolean>("buttons"),
presence.getSetting<boolean>("titleAsPresence"),
]),
path = document.location.pathname;

Expand Down Expand Up @@ -115,15 +116,25 @@ presence.on("UpdateData", async () => {
.querySelectorAll(".btn.is-outline")[7]
?.querySelector("span")?.textContent;

if (dub) {
presenceData.details =
if (dub || currentDub) {
/**
* This makes sure that the dub will always be defined.
* When user changes menu between dubs/subs, the menu items are different,
* so it's not possible to get the current active item if it's in a different menu.
*/
if (dub) currentDub = dub;

const title =
animeData.rus_name !== "" ? animeData.rus_name : animeData.name;

titleSetting
? (presenceData.name = title)
: (presenceData.details = title);
presenceData.state = `${
episode ? (episode.includes("эпизод") ? episode : "Фильм") : "Фильм"
} | ${dub}`;
} | ${currentDub}`;
presenceData.largeImageKey = animeData.cover.default;
presenceData.largeImageText =
animeData.rus_name !== "" ? animeData.rus_name : animeData.name;
presenceData.largeImageText = title;
presenceData.buttons = [
{
label: "Открыть аниме",
Expand Down
42 changes: 42 additions & 0 deletions websites/B/Brave Search/Brave Search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"bravesearch.settings": {
"description": "Page name",
"message": "Viewing their settings..."
},
"bravesearch.help": {
"description": "Page name",
"message": "Help Center"
},
"bravesearch.searchImgFor": {
"description": "Displayed when the user is searching for an image. The search query will be displayed below.",
"message": "Searching images for:"
},
"bravesearch.searchImgSomething": {
"description": "Displayed when the user is searching for an image.",
"message": "Searching up images..."
},
"bravesearch.searchNewsFor": {
"description": "Displayed when the user is searching for a news. The search query will be displayed below.",
"message": "Searching news for:"
},
"bravesearch.searchNewsSomething": {
"description": "Displayed when the user is searching for a news.",
"message": "Searching up news..."
},
"bravesearch.searchGogglesFor": {
"description": "Displayed when the user is searching for an goggle. The search query will be displayed below.",
"message": "Searching goggles for:"
},
"bravesearch.searchGogglesSomething": {
"description": "Displayed when the user is searching for an goggle.",
"message": "Searching up goggles..."
},
"bravesearch.searchVidFor": {
"description": "Displayed when the user is searching for an video. The search query will be displayed below.",
"message": "Searching videos for:"
},
"bravesearch.searchVidSomething": {
"description": "Displayed when the user is searching for an video.",
"message": "Searching up videos..."
}
}
6 changes: 5 additions & 1 deletion websites/B/Brave Search/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"en": "Search the Web. Privately. Truly useful results, AI-powered answers, & more. All from an independent index. No profiling, no bias, no Big Tech."
},
"url": "search.brave.com",
"version": "1.0.2",
"version": "1.0.3",
"logo": "https://cdn.rcd.gg/PreMiD/websites/B/Brave%20Search/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/B/Brave%20Search/assets/thumbnail.png",
"color": "#FB542B",
Expand All @@ -24,6 +24,10 @@
"title": "Privacy Mode",
"icon": "fad fa-user-secret",
"value": false
},
{
"id": "lang",
"multiLanguage": true
}
]
}
61 changes: 48 additions & 13 deletions websites/B/Brave Search/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,42 @@ const enum Assets {
Logo = "https://cdn.rcd.gg/PreMiD/websites/B/Brave%20Search/assets/logo.png",
}

async function getStrings() {
return presence.getStrings({
search: "general.searchFor",
searchPrivate: "general.searchSomething",
home: "general.viewHome",
viewPage: "general.viewPage",
settings: "bravesearch.settings",
help: "bravesearch.help",
searchNews: "bravesearch.searchNewsFor",
searchNewsPrivate: "bravesearch.searchNewsSomething",
searchVid: "bravesearch.searchVidFor",
searchVidPrivate: "bravesearch.searchVidSomething",
searchImg: "bravesearch.searchImgFor",
searchImgPrivate: "bravesearch.searchImgSomething",
searchGoggles: "bravesearch.searchNewsFor",
searchGogglesPrivate: "bravesearch.searchNewsSomething",
});
}

let strings: Awaited<ReturnType<typeof getStrings>>,
oldLang: string = null;

presence.on("UpdateData", async () => {
const newLang = await presence.getSetting<string>("lang").catch(() => "en");

if (oldLang !== newLang || !strings) {
oldLang = newLang;
strings = await getStrings();
}

const { pathname } = document.location,
privacy = await presence.getSetting("privacy"),
presenceData: PresenceData = {
largeImageKey: Assets.Logo,
startTimestamp: browsingTimestamp,
details: "In Home",
details: strings.home,
state: privacy
? // eslint-disable-next-line no-undefined
undefined
Expand All @@ -22,37 +51,43 @@ presence.on("UpdateData", async () => {

switch (pathname.split("/")[1]) {
case "settings": {
presenceData.details = "Viewing Settings";
presenceData.details = strings.settings;
delete presenceData.state;
break;
}
case "help": {
if (!privacy) {
presenceData.details = "Viewing Help Page:";
presenceData.state = document
.querySelector(".post-title")
?.textContent?.trim();
} else presenceData.details = "Viewing Help Pages";
presenceData.details = strings.viewPage;
presenceData.state = !privacy
? document.querySelector(".post-title")?.textContent?.trim()
: strings.help;
break;
}
case "search": {
presenceData.details = `Searching${!privacy ? ":" : "..."}`;
presenceData.details = !privacy ? strings.search : strings.searchPrivate;
break;
}
case "images": {
presenceData.details = `Searching images${!privacy ? ":" : "..."}`;
presenceData.details = !privacy
? strings.searchImg
: strings.searchImgPrivate;
break;
}
case "news": {
presenceData.details = `Searching news${!privacy ? ":" : "..."}`;
presenceData.details = !privacy
? strings.searchNews
: strings.searchNewsPrivate;
break;
}
case "videos": {
presenceData.details = `Searching videos${!privacy ? ":" : "..."}`;
presenceData.details = !privacy
? strings.searchVid
: strings.searchVidPrivate;
break;
}
case "goggles": {
presenceData.details = `Searching goggles${!privacy ? ":" : "..."}`;
presenceData.details = !privacy
? strings.searchGoggles
: strings.searchGogglesPrivate;
break;
}
default: {
Expand Down
6 changes: 3 additions & 3 deletions websites/C/Claude/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"ja_JP": "Claude(クロード)とは、Anthropic社が開発した大規模言語モデルを用いた対話型生成AIである。2023年3月14日に一般公開され、以降複数のバージョンがリリースされている。\n\n2024年3月に公開されたClaude 3 OpusはメンサのIQテストでIQスコア101を記録した。「フレンドリーで熱心な同僚」をコンセプトの一つとしている。"
},
"url": "claude.ai",
"version": "1.0.0",
"logo": "https://i.imgur.com/t2w5Nso.png",
"thumbnail": "https://i.imgur.com/qFa0XUT.jpeg",
"version": "1.0.1",
"logo": "https://cdn.rcd.gg/PreMiD/websites/C/Claude/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Claude/assets/thumbnail.jpeg",
"color": "#DA7756",
"category": "other",
"tags": [
Expand Down
4 changes: 2 additions & 2 deletions websites/C/Claude/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ let oldLang: string = null,
strings: Awaited<ReturnType<typeof getStrings>>;

const enum Assets {
Logo = "https://i.imgur.com/t2w5Nso.png",
Talking = "https://i.imgur.com/rnAQvqx.png",
Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Claude/assets/logo.png",
Talking = "https://cdn.rcd.gg/PreMiD/websites/C/Claude/assets/0.png",
}

presence.on("UpdateData", async () => {
Expand Down
Loading

0 comments on commit 82010d0

Please sign in to comment.