Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor network request #57

Merged
merged 15 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ src/background_script.js
src/assets/js/stylish-reader-video-page.js
src/assets/css/stylish-reader-video-page-index.css
src/assets/css/stylish-reader-translation-panel-index.css
src/assets/css/translation-panel-index.css
src/assets/js/stylish-reader-translation-panel.js
src/assets/js/translation-panel.js
src/assets/js/youtube-transport.js
src/assets/js/stylish-reader-phrase-floating-panel.js
src/assets/css/stylish-reader-phrase-floating-panel-index.css
Expand Down
8 changes: 5 additions & 3 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Stylish Reader",
"description": "Help you learn English better and easier.",
"developer": { "name": "Toly Feng", "url": "https://stylishreader.com" },
"version": "0.0.10",
"version": "0.0.12",
"icons": {
"48": "icons/stylish-reader-48.png"
},
Expand All @@ -21,7 +21,8 @@
"web_accessible_resources": [
"assets/stylish-reader-48.png",
"assets/right-arrow.png",
"assets/cancel-button.png"
"assets/cancel-button.png",
"popup/dist/*"
],
"permissions": [
"activeTab",
Expand All @@ -37,6 +38,7 @@
"48": "icons/stylish-reader-48.png",
"96": "icons/stylish-reader-48.png"
},
"default_title": "Stylish Reader"
"default_title": "Stylish Reader",
"default_popup": "popup/dist/index.html"
}
}
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Stylish Reader",
"name": "stylish-reader",
"version": "0.0.1",
"description": "",
"scripts": {
Expand Down
10 changes: 0 additions & 10 deletions src/plugins/entryPoint/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ async function notifyClickEvent(type = "show", message = "default") {
});
}

// 处理 content script 发来的消息
function handleResponse(message) {
console.log(message);
}

// 处理错误
function handleError(error) {
console.log(`Error: ${error}`);
}

// 扩展图标被点击
async function extensionIconClicked(tab, clickEvent) {}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/general/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export async function initializeGeneralWebSite() {
listenEventFromBackgroundScript();
listenEventFromOfficialWebsite();
await injectTranslationFloatingPanelToShadowDom();
await injectPhraseFloatingPanelToShadowDom();
customizeGeneralEvent();
await createAndSetDefaultGroupForCurrentPage();
goThroughDomAndGenerateCustomElement(await getWordList());
// await injectPhraseFloatingPanelToShadowDom();
}
8 changes: 4 additions & 4 deletions src/plugins/general/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,17 +525,15 @@ async function createTranslationFloatingPanelToShadowDom(x = 0, y = 0) {
const styleElement = document.createElement("style");
styleElement.setAttribute("type", "text/css");
const cssCode = await injectCssToShadowDom(
"assets/css/stylish-reader-translation-panel-index.css"
"assets/css/translation-panel-index.css"
);
styleElement.appendChild(document.createTextNode(cssCode));

// 在shadow dom中添加挂载点
shadow.appendChild(mountPoint);

// 在shadow dom中添加脚本挂载点
const jsCode = await injectJsToShadowDom(
"assets/js/stylish-reader-translation-panel.js"
);
const jsCode = await injectJsToShadowDom("assets/js/translation-panel.js");
vueScript.textContent = jsCode;
shadow.appendChild(vueScript);

Expand All @@ -546,6 +544,7 @@ async function createTranslationFloatingPanelToShadowDom(x = 0, y = 0) {
document.body.appendChild(shadowRoot);

eval(vueScript.textContent);
return Promise.resolve();
}

function checkIfTranslationFloatingPanelExist() {
Expand Down Expand Up @@ -674,6 +673,7 @@ function convertStringToLowerCaseAndRemoveSpecialCharacter(s) {
.replaceAll("(", "")
.replaceAll(")", "")
.replaceAll("!", "")
.replaceAll("'", "")
.replaceAll(":", "");
}

Expand Down
Loading
Loading