diff --git a/.gitignore b/.gitignore
index 1329a34..8de894e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,9 +15,12 @@
.env.development.local
.env.test.local
.env.production.local
-
+.history
# secrets
secrets.*.js
v2.0.0
.idea
.vscode
+./history
+./.history
+
diff --git a/README.md b/README.md
index da2bb6d..bf52fb3 100644
--- a/README.md
+++ b/README.md
@@ -81,6 +81,8 @@ v2.1.0
- [x] Amazon 视频支持
+- [x] paramountplus 视频支持
+
- [x] Disneyplus 视频支持
- [x] Yandex 翻译接口接入
@@ -89,7 +91,7 @@ v2.1.0
- [x] 百度翻译接口接入
-- [x] deepl接口接入
+- [x] deepl 接口接入
- [x] 控制面板
@@ -119,7 +121,7 @@ v2.1.0
### 交流
-[tg交流](https://t.me/joinchat/Gs1RFzD5MpIwJ7S-)
+[tg 交流](https://t.me/joinchat/Gs1RFzD5MpIwJ7S-)
diff --git a/README_en.md b/README_en.md
index a5778cd..9c3201b 100644
--- a/README_en.md
+++ b/README_en.md
@@ -77,6 +77,8 @@ v2.1.0
- [x] Amazon video support
+- [x] paramountplus video support
+
- [x] Disneyplus video support
- [x] Yandex translate Api support
diff --git a/package.json b/package.json
index c8c5f7a..5d67e76 100755
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "chrome-extension-udemy-translate",
- "version": "2.1.1",
+ "version": "2.1.2",
"description": "Translate Udemy's subtitles into Chinese/English(netflix+udemy+lynda+hulu+hbo now字幕翻译)",
"license": "MIT",
"repository": {
diff --git a/src/manifest.json b/src/manifest.json
index 36dfa2e..a4d166d 100755
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -1,55 +1,58 @@
{
- "name": "Udemy Translate",
- "options_page": "options.html",
- "background": {
- "page": "background.html",
- "persistent": false
- },
- "browser_action": {
- "default_popup": "popup.html",
- "default_icon": "icon-48.png"
- },
- "devtools_page": "devtools.html",
- "permissions": [
- "http://*/*",
- "https://*/*",
- "tabs",
- "contextMenus",
- "notifications",
- "webRequestBlocking",
- "storage",
- "activeTab",
- "declarativeContent"
- ],
- "icons": {
- "128": "icon-128.png"
- },
- "content_scripts": [{
- "matches": [
- "https://*.udemy.com/*",
- "https://*.youtube.com/*",
- "https://*.netflix.com/*",
- "https://*.lynda.com/*",
- "https://*.hbonow.com/*",
- "https://*.hbomax.com/*",
- "https://*.hulu.com/*",
- "https://*.primevideo.com/*",
- "https://*.amazon.com/*",
- "https://*.amazon.com/gp/*",
- "https://*.amazon.co.uk/*",
- "https://*.amazon.de/*",
- "https://*.amazon.co.jp/*",
- "https://*.disneyplus.com/*"
- ],
- "js": ["contentScript.bundle.js"],
- "css": ["content.styles.scss"],
- "run_at": "document_start"
- }],
- "web_accessible_resources": [
- "content.styles.scss",
- "icon-128.png",
- "icon-48.png"
- ],
- "manifest_version": 2,
- "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
-}
\ No newline at end of file
+ "name": "Udemy Translate",
+ "options_page": "options.html",
+ "background": {
+ "page": "background.html",
+ "persistent": false
+ },
+ "browser_action": {
+ "default_popup": "popup.html",
+ "default_icon": "icon-48.png"
+ },
+ "devtools_page": "devtools.html",
+ "permissions": [
+ "http://*/*",
+ "https://*/*",
+ "tabs",
+ "contextMenus",
+ "notifications",
+ "webRequestBlocking",
+ "storage",
+ "activeTab",
+ "declarativeContent"
+ ],
+ "icons": {
+ "128": "icon-128.png"
+ },
+ "content_scripts": [
+ {
+ "matches": [
+ "https://*.udemy.com/*",
+ "https://*.youtube.com/*",
+ "https://*.netflix.com/*",
+ "https://*.lynda.com/*",
+ "https://*.hbonow.com/*",
+ "https://*.hbomax.com/*",
+ "https://*.hulu.com/*",
+ "https://*.primevideo.com/*",
+ "https://*.amazon.com/*",
+ "https://*.amazon.com/gp/*",
+ "https://*.amazon.co.uk/*",
+ "https://*.amazon.de/*",
+ "https://*.amazon.co.jp/*",
+ "https://*.disneyplus.com/*",
+ "https://www.paramountplus.com/*"
+ ],
+ "js": ["contentScript.bundle.js"],
+ "css": ["content.styles.scss"],
+ "run_at": "document_start"
+ }
+ ],
+ "web_accessible_resources": [
+ "content.styles.scss",
+ "icon-128.png",
+ "icon-48.png"
+ ],
+ "manifest_version": 2,
+ "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
+}
diff --git a/src/pages/Content/VideoType/paramountplus.ts b/src/pages/Content/VideoType/paramountplus.ts
new file mode 100644
index 0000000..7c84c9a
--- /dev/null
+++ b/src/pages/Content/VideoType/paramountplus.ts
@@ -0,0 +1,59 @@
+/**
+ * www.paramountplus.com
+ */
+
+import { getItem } from '../modules/localStorage';
+import { dealSubtitle } from '../modules/utils.ts';
+
+const sub = {
+ pre: '',
+ current: '',
+};
+
+let time = null;
+const run = async () => {
+ try {
+ console.log('-----------seraching...-------------');
+ if ($('video') !== null) {
+ let plugin_status = await getItem('status');
+ if (plugin_status) {
+ let current = $('video')[0].textTracks[0].activeCues[0].text;
+ current = current
+ .replace('
', ' ')
+ .replace(/\[(.+)\]/, '')
+ .replace(//g, '')
+ .replace(/<\/i>/g, ' ')
+ .replace(/\n/g, ' ');
+
+ // when change send request ,then make same
+ if (sub.pre !== current && current !== '') {
+ sub.pre = current;
+ console.log(sub);
+ // send message to background
+ if (typeof chrome.app.isInstalled !== 'undefined') {
+ chrome.runtime.sendMessage({ text: current });
+ }
+ }
+ } else {
+ // close plugin
+ // clearInterval(time);
+ await $('style[id=chrome-extension-plugin-css]').remove();
+ await $('.SUBTILTE').remove();
+ }
+ }
+ } catch (e) {
+ console.log(`can't find subtitle`);
+ }
+};
+time = setInterval(run, 100);
+
+chrome.runtime.onMessage.addListener(async function(
+ request,
+ sender,
+ sendResponse
+) {
+ console.log(JSON.stringify(request));
+ if (sub.current !== sub.pre) {
+ dealSubtitle('video', request);
+ }
+});
diff --git a/src/pages/Content/index.ts b/src/pages/Content/index.ts
index a454720..e9c5dc9 100644
--- a/src/pages/Content/index.ts
+++ b/src/pages/Content/index.ts
@@ -7,9 +7,10 @@ const hrefMap = {
hulu: 'hulu',
amazon: 'amazon',
hbo: 'hbo',
- hbomax:'hbomax',
+ hbomax: 'hbomax',
primevideo: 'primevideo',
disneyplus: 'disneyplus',
+ paramountplus: 'paramountplus',
};
const whatsPage = (href) => {
@@ -26,35 +27,38 @@ console.log(
whatsPage(window.location.href)
);
-switch (whatsPage(window.location.href)) {
- case 'udemy':
- require('./VideoType/udemy.ts');
- break;
- case 'netflix':
- require('./VideoType/netflix.ts');
- break;
- case 'lynda':
- require('./VideoType/lynda.ts');
- break;
- case 'hulu':
- require('./VideoType/hulu.ts');
- break;
- case 'amazon':
- require('./VideoType/amazon.ts');
- break;
- case 'hbo':
- require('./VideoType/hbo.ts');
- break;
- case 'hbomax':
- require('./VideoType/hbomax.ts');
- break;
- case 'primevideo':
- require('./VideoType/primevideo.ts');
- break;
- case 'disneyplus':
- require('./VideoType/disneyplus.ts');
- break;
-}
+require(`./VideoType/${hrefMap[whatsPage(window.location.href)]}.ts`);
+// switch (whatsPage(window.location.href)) {
+// case 'udemy':
+// require('./VideoType/udemy.ts');
+// break;
+// case 'netflix':
+// require('./VideoType/netflix.ts');
+// break;
+// case 'lynda':
+// require('./VideoType/lynda.ts');
+// break;
+// case 'hulu':
+// require('./VideoType/hulu.ts');
+// break;
+// case 'amazon':
+// require('./VideoType/amazon.ts');
+// break;
+// case 'hbo':
+// require('./VideoType/hbo.ts');
+// break;
+// case 'hbomax':
+// require('./VideoType/hbomax.ts');
+// break;
+// case 'primevideo':
+// require('./VideoType/primevideo.ts');
+// break;
+// case 'disneyplus':
+// require('./VideoType/disneyplus.ts');
+// case 'paramountplus':
+// require('./VideoType/paramountplus.ts');
+// break;
+// }
console.log('Content script works!');
console.log('Must reload extension for modifications to take effect.');