Skip to content

Commit a27fdce

Browse files
authored
Merge pull request #152 from vrc-plugin/support-jinnai-system
feat: support jinnai system
2 parents 23aebd3 + dcd9a57 commit a27fdce

File tree

6 files changed

+73
-3
lines changed

6 files changed

+73
-3
lines changed

Diff for: src/background.ts

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { getUseJinnaiSystem } from "./config";
2+
13
const CONTEXT_MENUS = {
24
SEND_THIS_PAGE: "send_this_page",
35
SEND_WITH_CLIPBOARD: "send_with_clipboard",
6+
OPEN_OPTIONS: "open_options",
47
};
58

69
const ERROR_NOTIFICATION_OPTIONS: chrome.notifications.NotificationOptions<true> =
@@ -12,14 +15,23 @@ const ERROR_NOTIFICATION_OPTIONS: chrome.notifications.NotificationOptions<true>
1215
} as const;
1316

1417
const sendUrlToVRC = async (url: string) => {
18+
let body: { url: string };
19+
if (await getUseJinnaiSystem()) {
20+
const jinnaiSystemUrl = new URL("https://nextnex.com/");
21+
jinnaiSystemUrl.searchParams.set("url", url);
22+
body = { url: jinnaiSystemUrl.toString() };
23+
} else {
24+
body = { url };
25+
}
26+
1527
try {
1628
const res = await fetch("http://localhost:11400/url", {
1729
method: "POST",
1830
mode: "cors",
1931
credentials: "omit",
2032
cache: "no-cache",
2133
headers: { "Content-Type": "application/json" },
22-
body: JSON.stringify({ url: url }),
34+
body: JSON.stringify(body),
2335
});
2436

2537
if (!res.ok) {
@@ -72,6 +84,13 @@ chrome.contextMenus.create({
7284
contexts: ["action"],
7385
});
7486

87+
chrome.contextMenus.create({
88+
id: CONTEXT_MENUS.OPEN_OPTIONS,
89+
title: "Options",
90+
type: "normal",
91+
contexts: ["action"],
92+
});
93+
7594
chrome.contextMenus.onClicked.addListener(async (info, tab) => {
7695
switch (info.menuItemId) {
7796
case CONTEXT_MENUS.SEND_THIS_PAGE: {
@@ -92,6 +111,10 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => {
92111
sendUrlToVRC(clipboardText);
93112
break;
94113
}
114+
case CONTEXT_MENUS.OPEN_OPTIONS: {
115+
chrome.tabs.create({ url: "options.html" });
116+
break;
117+
}
95118
}
96119
});
97120

Diff for: src/config.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export async function getUseJinnaiSystem(): Promise<boolean> {
2+
const { useJinnaiSystem } = await chrome.storage.local.get("useJinnaiSystem");
3+
return useJinnaiSystem ?? false;
4+
}
5+
6+
export function setUseJinnaiSystem(value: boolean): Promise<void> {
7+
return chrome.storage.local.set({
8+
useJinnaiSystem: value,
9+
});
10+
}

Diff for: src/options.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { getUseJinnaiSystem, setUseJinnaiSystem } from "./config";
2+
3+
const useJinnaiSystemInput = document.getElementById(
4+
"useJinnaiSystem"
5+
) as HTMLInputElement;
6+
7+
useJinnaiSystemInput.addEventListener("change", () => {
8+
setUseJinnaiSystem(useJinnaiSystemInput.checked);
9+
});
10+
11+
window.addEventListener("load", async () => {
12+
const useJinnaiSystem = await getUseJinnaiSystem();
13+
useJinnaiSystemInput.checked = useJinnaiSystem;
14+
});

Diff for: static/manifest.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
"version": "1.1.1",
55
"description": "Sends the URL to VRChat. send_vrc_desktop is required for one-click operation.",
66
"action": {
7-
"default_icon": "icon.png",
7+
"default_icon": {
8+
"16": "icon.png",
9+
"24": "icon.png",
10+
"32": "icon.png"
11+
},
812
"default_title": "this page send to VRChat"
913
},
1014
"icons": {
@@ -18,7 +22,8 @@
1822
"contextMenus",
1923
"clipboardRead",
2024
"notifications",
21-
"scripting"
25+
"scripting",
26+
"storage"
2227
],
2328
"host_permissions": ["http://localhost:11400/*"]
2429
}

Diff for: static/options.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="ja">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>SendVRC Options</title>
8+
</head>
9+
<body>
10+
<h1>SendVRC Options</h1>
11+
<div>
12+
<input id="useJinnaiSystem" type="checkbox" />
13+
<label for="useJinnaiSystem">Use Jinnai system</label>
14+
</div>
15+
<script src="options.js"></script>
16+
</body>
17+
</html>

Diff for: webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
mode: process.env.NODE_ENV || "development",
88
entry: {
99
background: path.join(__dirname, "src/background.ts"),
10+
options: path.join(__dirname, "src/options.ts"),
1011
},
1112
output: {
1213
path: path.join(__dirname, "dist"),

0 commit comments

Comments
 (0)