├── screenshot.png
├── .idea
├── .gitignore
├── vcs.xml
├── modules.xml
└── VideoStudyTool.iml
├── README.md
├── js
├── content.js
├── background.js
├── popup.js
└── FileSaver.js
├── manifest.json
├── popup.html
└── css
└── popup.css
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lianliankanm/ChromeVideoOcrTool/HEAD/screenshot.png
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ChromeVideoOcrTool 视频文字识别插件
2 | ##v1.0: 视频单张截图文字识别
3 | ##v1.1: 视频选择多张截图文字识别
4 | ##v1.2: 自由截取视频片段进行文字识别
5 | ##v1.3: 连接后端识别接口
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/VideoStudyTool.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/js/content.js:
--------------------------------------------------------------------------------
1 |
2 | chrome.runtime.onMessage.addListener(//监听扩展程序进程或内容脚本发送的请求
3 | (message, sender, sendResponse)=> {
4 | console.log(message.greeting);
5 | if (message.greeting === "GetVideo") {
6 | console.log("getVideo");
7 | let video = document.getElementsByTagName("video")[0];
8 | let canvas = document.createElement("canvas");
9 | let ctx = canvas.getContext("2d");
10 | // console.log(video.videoWidth);
11 | canvas.width = video.videoWidth;
12 | canvas.height = video.videoHeight;
13 | ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
14 |
15 | sendResponse({src:canvas.toDataURL()});
16 |
17 | }
18 | return true;
19 | }
20 | );
--------------------------------------------------------------------------------
/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "VideoStudyTool",
3 | "version": "1.3",
4 | "manifest_version": 2, // 必须字段,且值为 2
5 | "description": "提取网页正在播放的视频中的文字",
6 |
7 | // 在chrome主工具条的地址栏右侧增加一个图标
8 | "browser_action": {
9 | // "page_action": {
10 | "default_icon": "screenshot.png",
11 | "default_title": "提取网页正在播放的视频中的文字",
12 | "default_popup": "popup.html"
13 | },
14 |
15 | // 注入脚本来管理一些任务或者状态,在扩展的整个生命周期都会存在
16 | "background": {
17 | "scripts": ["js/FileSaver.js", "js/background.js","js/jquery.js"]
18 | },
19 |
20 | // 在当前页面内运行的JavaScript脚本,可以直接获取当前页面的DOM并可以对DOM进行修改
21 | "content_scripts": [
22 | {
23 | "matches": ["*://*/*"], // 定义在哪些页面注入content_script
24 | "js": ["js/jquery.js", "js/content.js"],
25 | "run_at": "document_start" //在document加载时执行该脚本
26 | }
27 | ],
28 |
29 | // 设置插件的权限
30 | "permissions": [
31 | "",
32 | "tabs",
33 | "activeTab",
34 | "contextMenus",
35 | "webRequest", // web请求
36 | "storage",
37 | "declarativeContent"
38 | ]
39 | }
40 |
41 | // 注:前三个字段为必须字段
--------------------------------------------------------------------------------
/popup.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 视频识别工具
5 |
6 |
7 |
8 |
9 |
15 |
16 |
![请开始截图]()
17 |
18 |
19 |
20 | 清空截图
21 |
22 |
23 | 取消当前截图
24 |
25 |
26 |
31 |
32 |
35 |
36 |
37 | 保存到本地
38 |
39 |
40 | 清空文本框
41 |
42 |
43 | 复制到剪切板
44 |
45 |
46 | 内容翻译
47 |
48 |
49 |
50 |
51 |
52 | 开始
53 |
54 |
55 | 清空视频片段
56 |
57 |
58 |
59 | 识别截取视频片段 共 0 秒
60 |
61 |
62 | 跳转至应用主页 体验更多功能
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/css/popup.css:
--------------------------------------------------------------------------------
1 | .container {
2 | width: 300px;
3 | height: 80px;
4 | text-align: center;
5 | }
6 | .screenshot-btn {
7 | display: inline-block;
8 | /*width: 100px;*/
9 | border: 1px solid #000;
10 | background-color: #a4efbc;
11 | cursor: pointer;
12 | text-align: center;
13 | margin: 0 15px;
14 | margin-top: 25px;
15 | }
16 | .screenshot-btn p {
17 | height: 30px;
18 | line-height: 30px;
19 | margin: 0;
20 | /*color: #fff;*/
21 | }
22 | .screenshot-btn:hover {
23 | /*background-color: #2d78f4;*/
24 | }
25 |
26 | .ocr p{
27 | border:1px solid #000000;
28 | cursor: pointer;
29 | background-color: #ffef83;
30 | }
31 |
32 | .operation{
33 | column-count: 2;
34 | }
35 | .clear{
36 |
37 |
38 | border:1px solid #000000;
39 | cursor: pointer;
40 | }
41 |
42 | .undo{
43 | border:1px solid #000000;
44 | cursor: pointer;
45 | }
46 |
47 | .video-ocr{
48 | column-count: 2;
49 | }
50 | .switch{
51 | border:1px solid #000000;
52 | cursor: pointer;
53 | background-color: #a4efbc;
54 |
55 | }
56 | .clear-video{
57 |
58 |
59 | border:1px solid #000000;
60 | cursor: pointer;
61 | }
62 | .video-req{
63 | border:1px solid #000000;
64 | cursor: pointer;
65 | background-color: #ffef83;
66 | margin: 5px 0;
67 | }
68 | /*.video-req p{*/
69 | /* color: #fff;*/
70 | /*}*/
71 | .text-control{
72 | width: 80px;
73 | column-count: 1;
74 | /*display: inline-block;*/
75 | }
76 | .textarea{
77 | width: 200px;
78 | /*display: inline-block;*/
79 | }
80 | .save{
81 | border:1px solid #000000;
82 | cursor: pointer;
83 | }
84 | .clear-text{
85 | border:1px solid #000000;
86 | cursor: pointer;
87 | margin: 5px 0;
88 | }
89 | .copy-text{
90 | border:1px solid #000000;
91 | cursor: pointer;
92 | margin: 5px 0;
93 | }
94 | .tran{
95 | border:1px solid #000000;
96 | cursor: pointer;
97 | }
98 | .text-area{
99 | display: flex;
100 | justify-content: space-around;
101 | }
102 |
103 | .open{
104 | border:1px solid #000000;
105 | cursor: pointer;
106 | width: 180px;
107 | float: right;
108 | }
--------------------------------------------------------------------------------
/js/background.js:
--------------------------------------------------------------------------------
1 | // Page action条件:页面中含有video标签
2 | chrome.runtime.onInstalled.addListener(function() {
3 | chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
4 | chrome.declarativeContent.onPageChanged.addRules([{
5 | conditions: [
6 | // When a page contains a