Skip to content
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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Stylish Reader

[![Stylish Reader Extension CI](https://github.com/tolerious/Stylish-Reader/actions/workflows/node.js.yml/badge.svg?branch=master)](https://github.com/tolerious/Stylish-Reader/actions/workflows/node.js.yml)

Firefox extension that helps you learn English better and easier.
Expand All @@ -8,14 +9,10 @@ Firefox extension that helps you learn English better and easier.
- [x] Translate the selected word/phrase/sentence from English to Chinese.
- [x] Collect/Favorite new word.
- [x] Recite the collected word.
- [x] See the real-time bilingual live subtitles while watching TED videos.

## TODO List
- [x] See the real-time bilingual live subtitles while watching Youtube videos.
- [x] Save `The Guardian` article automatically for later test.

- [ ] Official website established.
- [ ] Refactor English-Burning APP for better user experience.
- [ ] BBC Learning English(6 minutes English) supported.
- [ ] Collect/Favorite articles, provide reading mode afterwards.
For more features, you could have a look at the [official website.](https://stylishreader.com/#/)

## Highlight and search words

Expand All @@ -33,3 +30,6 @@ Firefox extension that helps you learn English better and easier.
You can see the real-time bilingual live subtitles while watching TED videos.
![alt text](assets/image-1.png)

### Youtube video review

You can save the YouTube video to your account and see the real-time bilingual live subtitles later.
2 changes: 1 addition & 1 deletion 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.26",
"version": "0.0.27",
"icons": {
"48": "icons/stylish-reader-48.png"
},
Expand Down
12 changes: 9 additions & 3 deletions src/plugins/general/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export function goThroughDomAndGenerateCustomElement(targetWordList) {
let index = 0;
// 找到所有符合要求的#text节点,并保存在Map中
while (node) {

/**
* 找到当前node的父亲元素并排除script,HTML标签,这里排除HTML标签是因为HTML会包含所有文档元素,这不是我们想要的
* 且排除node的文本内容是空元素的
* */
if (
!["SCRIPT", "HTML"].includes(node.parentNode.nodeName) &&
node.textContent.trim() !== ""
Expand Down Expand Up @@ -100,10 +105,11 @@ function removeUnMarkedWord(word) {
}

function convertCurrentTextNodeContent(textNode, targetWordList) {
// 判断并找出当前文本节点中包含的目标单词
// 判断并找出当前文本节点中包含的目标单词,这里为什么要替换所有的\n,\t? 经过测试,替换了以后会改变一些文档结构
// const textContent = textNode.textContent
// .replaceAll("\n", " ")
// .replaceAll("\t", " ");
const textContent = textNode.textContent
.replaceAll("\n", " ")
.replaceAll("\t", " ");
const targetWordSet = new Set(targetWordList);
const splittedTextContentStringList = textContent.split(" ");
// 存放的是目标单词在splittedTextContentStringList中的索引
Expand Down