Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b4b3b020c | ||
|
|
3e96540b56 | ||
|
|
88b791bd73 | ||
|
|
7817019e70 | ||
|
|
6013bbd32c | ||
|
|
40e0b96f39 |
2
.env
2
.env
@@ -2,7 +2,7 @@ GENERATE_SOURCEMAP=false
|
|||||||
|
|
||||||
REACT_APP_NAME=KISS Translator
|
REACT_APP_NAME=KISS Translator
|
||||||
REACT_APP_NAME_CN=简约翻译
|
REACT_APP_NAME_CN=简约翻译
|
||||||
REACT_APP_VERSION=1.7.4
|
REACT_APP_VERSION=1.7.6
|
||||||
|
|
||||||
REACT_APP_HOMEPAGE=https://github.com/fishjar/kiss-translator
|
REACT_APP_HOMEPAGE=https://github.com/fishjar/kiss-translator
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "kiss-translator",
|
"name": "kiss-translator",
|
||||||
"description": "A minimalist bilingual translation Extension & Greasemonkey Script",
|
"description": "A minimalist bilingual translation Extension & Greasemonkey Script",
|
||||||
"version": "1.7.4",
|
"version": "1.7.6",
|
||||||
"author": "Gabe<yugang2002@gmail.com>",
|
"author": "Gabe<yugang2002@gmail.com>",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "__MSG_app_name__",
|
"name": "__MSG_app_name__",
|
||||||
"description": "__MSG_app_description__",
|
"description": "__MSG_app_description__",
|
||||||
"version": "1.7.4",
|
"version": "1.7.6",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"author": "Gabe<yugang2002@gmail.com>",
|
"author": "Gabe<yugang2002@gmail.com>",
|
||||||
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "__MSG_app_name__",
|
"name": "__MSG_app_name__",
|
||||||
"description": "__MSG_app_description__",
|
"description": "__MSG_app_description__",
|
||||||
"version": "1.7.4",
|
"version": "1.7.6",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"author": "Gabe<yugang2002@gmail.com>",
|
"author": "Gabe<yugang2002@gmail.com>",
|
||||||
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
MSG_TRANS_TOGGLE_STYLE,
|
MSG_TRANS_TOGGLE_STYLE,
|
||||||
MSG_TRANS_GETRULE,
|
MSG_TRANS_GETRULE,
|
||||||
MSG_TRANS_PUTRULE,
|
MSG_TRANS_PUTRULE,
|
||||||
|
APP_LCNAME,
|
||||||
} from "./config";
|
} from "./config";
|
||||||
import {
|
import {
|
||||||
getSettingWithDefault,
|
getSettingWithDefault,
|
||||||
@@ -93,7 +94,7 @@ const init = async () => {
|
|||||||
const fab = await getFabWithDefault();
|
const fab = await getFabWithDefault();
|
||||||
if (!fab.isHide) {
|
if (!fab.isHide) {
|
||||||
const $action = document.createElement("div");
|
const $action = document.createElement("div");
|
||||||
$action.setAttribute("id", "kiss-translator");
|
$action.setAttribute("id", APP_LCNAME);
|
||||||
document.body.parentElement.appendChild($action);
|
document.body.parentElement.appendChild($action);
|
||||||
const shadowContainer = $action.attachShadow({ mode: "closed" });
|
const shadowContainer = $action.attachShadow({ mode: "closed" });
|
||||||
const emotionRoot = document.createElement("style");
|
const emotionRoot = document.createElement("style");
|
||||||
@@ -101,7 +102,7 @@ const init = async () => {
|
|||||||
shadowContainer.appendChild(emotionRoot);
|
shadowContainer.appendChild(emotionRoot);
|
||||||
shadowContainer.appendChild(shadowRootElement);
|
shadowContainer.appendChild(shadowRootElement);
|
||||||
const cache = createCache({
|
const cache = createCache({
|
||||||
key: "css",
|
key: APP_LCNAME,
|
||||||
prepend: true,
|
prepend: true,
|
||||||
container: emotionRoot,
|
container: emotionRoot,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,19 +28,21 @@ export const fetchGM = async (input, { method = "GET", headers, body } = {}) =>
|
|||||||
url: input,
|
url: input,
|
||||||
headers,
|
headers,
|
||||||
data: body,
|
data: body,
|
||||||
onload: (response) => {
|
onload: ({ response, responseHeaders, status, statusText }) => {
|
||||||
if (response.status < 300) {
|
const headers = new Headers();
|
||||||
const headers = new Headers();
|
responseHeaders.split("\n").forEach((line) => {
|
||||||
response.responseHeaders.split("\n").forEach((line) => {
|
const [name, value] = line.split(":").map((item) => item.trim());
|
||||||
const [name, value] = line.split(":").map((item) => item.trim());
|
if (name && value) {
|
||||||
if (name && value) {
|
headers.append(name, value);
|
||||||
headers.append(name, value);
|
}
|
||||||
}
|
});
|
||||||
});
|
resolve(
|
||||||
resolve(new Response(response.response, { headers }));
|
new Response(response, {
|
||||||
} else {
|
headers,
|
||||||
reject(new Error(`[${response.status}] ${response.responseText}`));
|
status,
|
||||||
}
|
statusText,
|
||||||
|
})
|
||||||
|
);
|
||||||
},
|
},
|
||||||
onerror: reject,
|
onerror: reject,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
MSG_TRANS_TOGGLE_STYLE,
|
MSG_TRANS_TOGGLE_STYLE,
|
||||||
MSG_TRANS_GETRULE,
|
MSG_TRANS_GETRULE,
|
||||||
MSG_TRANS_PUTRULE,
|
MSG_TRANS_PUTRULE,
|
||||||
|
APP_LCNAME,
|
||||||
} from "./config";
|
} from "./config";
|
||||||
import { isIframe, sendIframeMsg, sendPrentMsg } from "./libs/iframe";
|
import { isIframe, sendIframeMsg, sendPrentMsg } from "./libs/iframe";
|
||||||
import { handlePing, injectScript } from "./libs/gm";
|
import { handlePing, injectScript } from "./libs/gm";
|
||||||
@@ -98,7 +99,7 @@ const init = async () => {
|
|||||||
// 浮球按钮
|
// 浮球按钮
|
||||||
const fab = await getFabWithDefault();
|
const fab = await getFabWithDefault();
|
||||||
const $action = document.createElement("div");
|
const $action = document.createElement("div");
|
||||||
$action.setAttribute("id", "kiss-translator");
|
$action.setAttribute("id", APP_LCNAME);
|
||||||
document.body.parentElement.appendChild($action);
|
document.body.parentElement.appendChild($action);
|
||||||
const shadowContainer = $action.attachShadow({ mode: "closed" });
|
const shadowContainer = $action.attachShadow({ mode: "closed" });
|
||||||
const emotionRoot = document.createElement("style");
|
const emotionRoot = document.createElement("style");
|
||||||
@@ -106,7 +107,7 @@ const init = async () => {
|
|||||||
shadowContainer.appendChild(emotionRoot);
|
shadowContainer.appendChild(emotionRoot);
|
||||||
shadowContainer.appendChild(shadowRootElement);
|
shadowContainer.appendChild(shadowRootElement);
|
||||||
const cache = createCache({
|
const cache = createCache({
|
||||||
key: "css",
|
key: APP_LCNAME,
|
||||||
prepend: true,
|
prepend: true,
|
||||||
container: emotionRoot,
|
container: emotionRoot,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user