├── LICENSE
├── README.md
├── README_zh_CN.md
├── _locales
├── en
│ └── messages.json
└── zh_CN
│ └── messages.json
├── analyzer.js
├── background.js
├── contentScript.js
├── default-128.png
├── icons
├── emoji_u1f47f.png
├── emoji_u1f4a1.png
├── emoji_u1f600.png
├── emoji_u1f601.png
├── emoji_u1f603.png
├── emoji_u1f608.png
├── emoji_u1f60a.png
├── emoji_u1f60b.png
├── emoji_u1f61f.png
├── emoji_u1f620.png
├── emoji_u1f621.png
├── emoji_u1f624.png
├── emoji_u1f62d.png
├── emoji_u1f631.png
├── emoji_u1f63a.png
├── emoji_u1f63c.png
├── emoji_u1f63e.png
├── emoji_u1f642.png
├── emoji_u1f92c.png
├── emoji_u203c.png
├── emoji_u2049.png
├── emoji_u2139.png
├── emoji_u2620.png
├── emoji_u2622.png
├── emoji_u2639.png
├── emoji_u26a0.png
├── emoji_u2753.png
├── emoji_u2757.png
└── emoji_ufe82b.png
├── manifest.json
├── options.html
├── options.js
├── oudated-128.png
├── popup.html
├── popup.js
└── webstore
├── command.md
├── screenshots
├── Screenshots-0.png
├── Screenshots-1.png
├── Screenshots-2.png
├── Screenshots-3.png
├── Screenshots-4.png
├── Screenshots-5.png
└── Screenshots-6.png
└── tile_images
├── 1400x560.png
├── 440x280.png
└── 920x680.png
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [中文版介绍](README_zh_CN.md)
2 |
3 | # Outdated-Doc-Detector
4 | Outdated-Doc-Detector is a Chrome extension to help non-English developers to check whether the translation of the current page is behind the corresponding English version.
5 |
6 | Chrome WebStore install link
7 |
8 | [](https://chrome.google.com/webstore/detail/outdated-doc-detector/enmpooegjbnbhifdpapjknlbjefnlnja)
9 |
10 | Google has some developer websites that support multiple languages. You can select one of these at the lower left/right corner of the page as your default display language. Many non-English developers prefer to use their language as the default display language. But these non-English documents are often behind it's corresponding English versions.
11 |
12 | **Outdated documents often lead to potential problems and are inconspicuous for developers.** This extension is used to indicate whether the ducument is out of date by comparing the updated time between non-English version and English version of the same page.
13 |
14 | # Instructions for use
15 | After installing the extension from Chrome webstore, it will show different extension icons when you visit the supported developer websites with non-English preference:
16 | - Smile icon: the updated time of current page is late than it's English version, so you are safe.
17 | - Warn icon: the updated time of current page is before the updated time of the English version, so you need to pay attention.
18 | - Dangerous icon: the updated time of current page is **long** before the updated time of the English version, so you need to check the English verion.
19 | - Inactive state icon: when you visit non-supported developer websites or the current page is English, the extension is in an inactive state.
20 |
21 | Note: This extension is implemented by [event pages](https://developer.chrome.com/extensions/event_pages) which are loaded only in a few seconds at the beginning of visiting the supported developer websites or clicking the extension icon. So it doesn't occupy your system resources.
22 |
23 | # Supported developer websites
24 | - MDN Web Docs: [developer.mozilla.org](https://developer.mozilla.org/)
25 | - Android Developers:[developer.android.com](https://developer.android.com) , [developer.android.google.cn](https://developer.android.google.cn) , [source.android.com](https://source.android.com) , [source.android.google.cn](https://source.android.google.cn)
26 | - Google Developers:[developers.google.com](https://developers.google.com) , [developers.google.cn](https://developers.google.cn)
27 | - Firebase Developers:[firebase.google.com](https://firebase.google.com) , [firebase.google.cn](https://firebase.google.cn)
28 | - Google Cloud Developers:[cloud.google.com](https://cloud.google.com)
29 | - TensorFlow Developers:[www.tensorflow.org](https://www.tensorflow.org) , [tensorflow.google.cn](https://tensorflow.google.cn)
30 |
31 | # Release Notes
32 | ### [1.2.0] - 2018-02-05
33 | - New feature: Support MDN Web Docs for web developers.
34 |
35 | ### [1.1.0] - 2017-09-08
36 | - New feature: Add warning banner in web pages and it's setting in the extension options page.
37 |
38 | ### [1.0.2] - 2017-09-02
39 | - New feature: Add keyboard shortcut for popup page, default is "Alt+Shift+E".
40 |
--------------------------------------------------------------------------------
/README_zh_CN.md:
--------------------------------------------------------------------------------
1 | # 过时文档检测器
2 | 过时文档检测器(Outdated Doc Detector)是一个 Chrome 浏览器扩展,帮助使用非英语的开发者检查当前页面的翻译内容是否落后于对应的英语版本。
3 |
4 | Chrome WebStore 安装地址
5 |
6 | [](https://chrome.google.com/webstore/detail/outdated-doc-detector/enmpooegjbnbhifdpapjknlbjefnlnja)
7 |
8 | 开发者网站提供了开发者经常需要查阅的关键文档,非常重要。
9 | 其中很多支持多语言版本,通过网站的左下角(或右下角)可以选择网站支持的一种语言作为默认显示的语言。
10 |
11 | 一般而言,这些网站的内容首先使用英语来撰写新内容或更新现有内容,然后发布。而其它语言的版本则由英语版内容翻译而来。
12 | 因此非英语版内容的更新时间一般要落后最新英语版内容一段时间,落后时间可能很短也可能长。
13 | 另外,由于技术更新快,很多英语版的文档会经常更新。而对应的其它语言版本则经常处于过时的状态。
14 | **过时的文档常常会误导开发者甚至导致软件问题,并且不易察觉。**
15 |
16 | 考虑到很多非英语母语的开发者还是更习惯看翻译版的文档,所以这个扩展主要就是面向这些开发者,
17 | 根据对比非英语版内容与英语版内容的文档更新时间来提醒开发者当前语言的文档是否已经过时。
18 |
19 | # 使用说明
20 | 从 Chrome WebStore 安装之后,当开发者访问扩展支持的网站时,扩展的图标会呈现如下不同状态:
21 | - 笑脸图标:当前语言的更新时间比英语版的更新时间新,这种状态认为是安全的。
22 | - 警告图标:当前语言的更新时间落后英语版一段时间,这种状态会呈现警告图标。
23 | - 危险图标:当前语言的更新时间落后英语版较长时间,这种状态会呈现危险图标。
24 | - 灰色不可用状态:如果当前页面不是扩展支持的网站或者当前页面语言为英语,则扩展图标处于灰色不可用状态。
25 |
26 | 在前三种图标状态下,点击扩展图标会显示当前页面的更新时间和最新英语版的更新时间。
27 |
28 | 特别说明:本扩展采用 [Event Pages](https://developer.chrome.com/extensions/event_pages) 技术实现,扩展不会常驻内存,不使用的时候不会消耗系统资源。
29 | 访问扩展不支持的网站时扩展完全不会激活。访问扩展支持的网站时仅在页面加载初期的几秒钟被激活,或者点击扩展图标时被激活。
30 | 其它时间扩展处于非激活状态、不消耗资源。可以从 Chrome 内置的任务管理器(Task Manager)中看到扩展是否处于激活状态。
31 |
32 | # 支持的开发者网站
33 | - MDN Web 文档: [developer.mozilla.org](https://developer.mozilla.org/)
34 | - Android 开发者:[developer.android.com](https://developer.android.com) , [developer.android.google.cn](https://developer.android.google.cn) , [source.android.com](https://source.android.com) , [source.android.google.cn](https://source.android.google.cn)
35 | - Google 开发者:[developers.google.com](https://developers.google.com) , [developers.google.cn](https://developers.google.cn)
36 | - Firebase 开发者:[firebase.google.com](https://firebase.google.com) , [firebase.google.cn](https://firebase.google.cn)
37 | - Google Cloud 开发者:[cloud.google.com](https://cloud.google.com)
38 | - TensorFlow 开发者:[www.tensorflow.org](https://www.tensorflow.org) , [tensorflow.google.cn](https://tensorflow.google.cn)
39 |
40 | # 版本说明
41 | ### [1.2.0] - 2018-02-05
42 | - 支持 MDN Web 文档.
43 |
44 | ### [1.1.0] - 2017-09-08
45 | - 添加页面内警告提示,可通过选项设置是否显示。
46 |
47 | ### [1.0.2] - 2017-09-02
48 | - 添加点击扩展的快捷键,默认是 "Alt+Shift+E"。
49 |
--------------------------------------------------------------------------------
/_locales/en/messages.json:
--------------------------------------------------------------------------------
1 | {
2 | "extName": {
3 | "message": "Outdated Doc Detector",
4 | "description": "This extension's name"
5 | },
6 | "extDescription": {
7 | "message": "Help non-English developers to check whether the translation of the current page is behind the corresponding English version."
8 | },
9 | "behindDays": {
10 | "message": "This page is $1 days behind the latest version."
11 | },
12 | "isUpToDate": {
13 | "message": "This page is the latest version."
14 | },
15 | "behindLessThanOneDay": {
16 | "message": "This page is a little behind the latest version."
17 | },
18 | "curPageUpdatedTime": {
19 | "message": "Last updated time of this page:
$1"
20 | },
21 | "enPageUpdatedTime": {
22 | "message": "Last updated time of the English version:
$1"
23 | },
24 | "note": {
25 | "message": "Note: "
26 | },
27 | "optionShowBannerLabel": {
28 | "message": " Show warning banner"
29 | }
30 | }
--------------------------------------------------------------------------------
/_locales/zh_CN/messages.json:
--------------------------------------------------------------------------------
1 | {
2 | "extName": {
3 | "message": "过时文档检测器",
4 | "description": "扩展名"
5 | },
6 | "extDescription": {
7 | "message": "帮助使用非英语的开发者检查当前页面的翻译内容是否落后于对应的英语版本。"
8 | },
9 | "behindDays": {
10 | "message": "当前页面落后最新版本 $1 天。"
11 | },
12 | "isUpToDate": {
13 | "message": "当前页面已是最新版本。"
14 | },
15 | "behindLessThanOneDay": {
16 | "message": "当前页面稍微落后最新版本。"
17 | },
18 | "curPageUpdatedTime": {
19 | "message": "当前页面的最后更新时间:
$1"
20 | },
21 | "enPageUpdatedTime": {
22 | "message": "英语版本的最后更新时间:
$1"
23 | },
24 | "note": {
25 | "message": "注意:"
26 | },
27 | "optionShowBannerLabel": {
28 | "message": " 显示警告"
29 | }
30 | }
--------------------------------------------------------------------------------
/analyzer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Analyzer base class for detecting document update time.
3 | * Note: subclass need to impelment these methods:
4 | * async findCurrentPageLastModified() {}
5 | * async findEnPageLastModified() {}
6 | * getEnPageUrl() {}
7 | */
8 | class Analyzer {
9 | /**
10 | * @return true if this page is English language.
11 | * if it is English page, analyzer do nothing.
12 | */
13 | isEn() {
14 | const lang = document.documentElement.lang;
15 | if(!lang || lang === "en" || lang === "en-US") {
16 | return true;
17 | } else {
18 | return false;
19 | }
20 | }
21 |
22 | async getHTTPLastModified(url) {
23 | try {
24 | const option = {
25 | method: 'HEAD',
26 | credentials: 'same-origin'
27 | }
28 | const response = await fetch(url, option);
29 | if(response.ok && response.headers.has("Last-Modified")) {
30 | // This is GMT timezone
31 | return new Date(response.headers.get("Last-Modified"));
32 | } else {
33 | return null;
34 | }
35 | } catch(e) {
36 | return null;
37 | }
38 | }
39 |
40 | /**
41 | * init an analyzer for current page.
42 | */
43 | static initAnalyzer() {
44 | // for MDN
45 | if(location.hostname === "developer.mozilla.org") {
46 | return new MDN();
47 | } else {
48 | return new GoogleSites();
49 | }
50 | }
51 | }
52 |
53 | /**
54 | * for MDN Web Docs
55 | */
56 | class MDN extends Analyzer {
57 | async findCurrentPageLastModified() {
58 | return this.findMDNPageLastModified(document);
59 | }
60 |
61 | async findEnPageLastModified() {
62 | const enURL = this.getEnPageUrl();
63 | if(enURL) {
64 | const response = await fetch(enURL);
65 | const html = await response.text();
66 | const enHTML = new DOMParser().parseFromString(html, 'text/html');
67 | return this.findMDNPageLastModified(enHTML);
68 | }
69 | return null;
70 | }
71 |
72 | getEnPageUrl() {
73 | // replace developer.mozilla.org/zh-CN/ to /en-US/
74 | const enAlternate = document.head.querySelector("link[rel=alternate][hreflang=en-US]")
75 | || document.head.querySelector("link[rel=alternate][hreflang=en]");
76 | return enAlternate ? enAlternate.href : null;
77 | }
78 |
79 | // curent page and english page are the same method
80 | findMDNPageLastModified(dom) {
81 | // a time element
82 | const lastUpdateTime = dom.querySelector(".last-modified-date time");
83 | if(lastUpdateTime) {
84 | return new Date(lastUpdateTime.dateTime);
85 | }
86 | return null;
87 | }
88 | }
89 |
90 | /**
91 | * for other Google Dev Sites
92 | */
93 | class GoogleSites extends Analyzer {
94 | async findCurrentPageLastModified() {
95 | // for android dev site
96 | //
97 | const meta = document.head.querySelector("meta[itemprop='dateModified'");
98 | if(meta) {
99 | return this.getDateAsUTC(meta.content);
100 | }
101 |
102 | // default use http header
103 | return await this.getHTTPLastModified(document.location.href);
104 | }
105 |
106 | async findEnPageLastModified() {
107 | // this is ok for supported google sites, don't analyze page content.
108 | return await this.getHTTPLastModified(this.getEnPageUrl());
109 | }
110 |
111 | getEnPageUrl() {
112 | const params = new URLSearchParams(location.search);
113 | // set ?hl=en param
114 | params.set('hl', 'en');
115 | return `${location.pathname}?${params}`;
116 | }
117 |
118 | getDateAsUTC(datestr) {
119 | return new Date(datestr + 'Z')
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/background.js:
--------------------------------------------------------------------------------
1 | function show(request, sender, sendResponse) {
2 | if(!sender.tab) {
3 | return;
4 | }
5 |
6 | const tabId = sender.tab.id;
7 | chrome.action.enable(tabId);
8 |
9 | if(request.reset) {
10 | chrome.action.setIcon({tabId: tabId, path: 'oudated-128.png'});
11 | return;
12 | }
13 |
14 | const oneDay = 3600*24*1000;
15 | const diff = request.oriUpdateTime - request.curUpdateTime;
16 | if(diff <= 60*30*1000) { // up to date or less than 30min
17 | chrome.action.setIcon({tabId: tabId, path: 'icons/emoji_u1f600.png'});
18 | } else if(diff < oneDay*45) { // warning
19 | chrome.action.setIcon({tabId: tabId, path: 'icons/emoji_u26a0.png'});
20 | } else { // dangerous
21 | chrome.action.setIcon({tabId: tabId, path: 'icons/emoji_u2620.png'});
22 | }
23 | }
24 |
25 | function onStartup() {
26 | chrome.action.disable();
27 | }
28 |
29 | chrome.runtime.onInstalled.addListener(onStartup);
30 | chrome.runtime.onStartup.addListener(onStartup);
31 | chrome.runtime.onMessage.addListener(show);
--------------------------------------------------------------------------------
/contentScript.js:
--------------------------------------------------------------------------------
1 | // global data object
2 | var pageData = null;
3 |
4 | async function init() {
5 | const analyzer = Analyzer.initAnalyzer();
6 | if(analyzer.isEn()) {
7 | return
8 | }
9 |
10 | const curUpdateTime = await analyzer.findCurrentPageLastModified();
11 | if(!curUpdateTime) {
12 | return
13 | }
14 |
15 | const oriUpdateTime = await analyzer.findEnPageLastModified();
16 | if(!oriUpdateTime) {
17 | return
18 | }
19 |
20 | // console.log("curUpdateTime: " + curUpdateTime);
21 | // console.log("oriUpdateTime: " + oriUpdateTime);
22 |
23 | pageData = {
24 | oriUpdateTime: oriUpdateTime.getTime(),
25 | curUpdateTime: curUpdateTime.getTime(),
26 | enURL: analyzer.getEnPageUrl(),
27 | curURL: document.location.href
28 | }
29 |
30 | const data = {
31 | oriUpdateTime: oriUpdateTime.getTime(),
32 | curUpdateTime: curUpdateTime.getTime()
33 | }
34 | // send to event page to show icon.
35 | chrome.runtime.sendMessage(data);
36 |
37 | // show warning banner
38 | chrome.storage.sync.get({
39 | showBanner: true // default true
40 | }, function(items) {
41 | if(items.showBanner) {
42 | showBanner();
43 | }
44 | });
45 | }
46 |
47 | /**
48 | * Show warning banner in the page.
49 | * This is the same logic with popup.js
50 | */
51 | var banner;
52 | function showBanner() {
53 | const diff = pageData.oriUpdateTime - pageData.curUpdateTime;
54 | if(diff <= 60*30*1000) { // up to date or less than 30min
55 | return;
56 | }
57 |
58 | if(!banner || !document.body.contains(banner)) {
59 | banner = document.createElement('div');
60 | banner.style.cssText = "position:fixed; width: 314px; margin-left: -157px; top: 12%; left: 50%; color: blue; border: 2px solid red; background-color: yellow; z-index: 1000000; font-size: 12px; padding: 3px;";
61 | // note element
62 | const note = document.createElement('span');
63 | banner.appendChild(note);
64 | // close element
65 | const close = document.createElement('span');
66 | close.innerText = "[X]";
67 | close.title = "close";
68 | close.style.cssText = "cursor: pointer;";
69 | close.onclick = function(){
70 | banner.remove();
71 | banner = null;
72 | };
73 | banner.appendChild(close);
74 | document.body.appendChild(banner);
75 | }
76 |
77 | // update
78 | const oneDay = 3600*24*1000;
79 | const noteString = chrome.i18n.getMessage("note");
80 | if(diff >= oneDay) { // behind more than 1 days
81 | const days = Math.trunc(diff/oneDay);
82 | banner.firstElementChild.innerHTML = noteString + chrome.i18n.getMessage("behindDays", [days, pageData.enURL]);
83 | } else if(diff > 0) { // behind less than 1 day
84 | banner.firstElementChild.innerHTML = noteString + chrome.i18n.getMessage("behindLessThanOneDay", [pageData.enURL]);
85 | }
86 | }
87 |
88 | // reponse popup to get page info.
89 | chrome.runtime.onMessage.addListener(
90 | function(request, sender, sendResponse) {
91 | if(sender.tab) {
92 | return;
93 | }
94 | sendResponse(pageData);
95 | }
96 | );
97 |
98 | function watchUrlChanged() {
99 | let metaURL = document.head.querySelector("meta[property='og:url']");
100 | if(metaURL) {
101 | let config = { childList: true };
102 | let observer = new MutationObserver((list, observer) => {
103 | for(const mutation of list) {
104 | for(const node of mutation.addedNodes) {
105 | if(node.getAttribute('property') === "og:url") {
106 | console.log('url changed')
107 | if(banner) {
108 | banner.remove();
109 | banner = null;
110 | chrome.runtime.sendMessage({reset: true});
111 | }
112 | init();
113 | return;
114 | }
115 | }
116 | }
117 | });
118 | observer.observe(document.head, config);
119 | }
120 | }
121 |
122 | init();
123 | watchUrlChanged();
124 |
--------------------------------------------------------------------------------
/default-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/default-128.png
--------------------------------------------------------------------------------
/icons/emoji_u1f47f.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f47f.png
--------------------------------------------------------------------------------
/icons/emoji_u1f4a1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f4a1.png
--------------------------------------------------------------------------------
/icons/emoji_u1f600.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f600.png
--------------------------------------------------------------------------------
/icons/emoji_u1f601.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f601.png
--------------------------------------------------------------------------------
/icons/emoji_u1f603.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f603.png
--------------------------------------------------------------------------------
/icons/emoji_u1f608.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f608.png
--------------------------------------------------------------------------------
/icons/emoji_u1f60a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f60a.png
--------------------------------------------------------------------------------
/icons/emoji_u1f60b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f60b.png
--------------------------------------------------------------------------------
/icons/emoji_u1f61f.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f61f.png
--------------------------------------------------------------------------------
/icons/emoji_u1f620.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f620.png
--------------------------------------------------------------------------------
/icons/emoji_u1f621.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f621.png
--------------------------------------------------------------------------------
/icons/emoji_u1f624.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f624.png
--------------------------------------------------------------------------------
/icons/emoji_u1f62d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f62d.png
--------------------------------------------------------------------------------
/icons/emoji_u1f631.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f631.png
--------------------------------------------------------------------------------
/icons/emoji_u1f63a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f63a.png
--------------------------------------------------------------------------------
/icons/emoji_u1f63c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f63c.png
--------------------------------------------------------------------------------
/icons/emoji_u1f63e.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f63e.png
--------------------------------------------------------------------------------
/icons/emoji_u1f642.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f642.png
--------------------------------------------------------------------------------
/icons/emoji_u1f92c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u1f92c.png
--------------------------------------------------------------------------------
/icons/emoji_u203c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u203c.png
--------------------------------------------------------------------------------
/icons/emoji_u2049.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u2049.png
--------------------------------------------------------------------------------
/icons/emoji_u2139.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u2139.png
--------------------------------------------------------------------------------
/icons/emoji_u2620.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u2620.png
--------------------------------------------------------------------------------
/icons/emoji_u2622.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u2622.png
--------------------------------------------------------------------------------
/icons/emoji_u2639.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u2639.png
--------------------------------------------------------------------------------
/icons/emoji_u26a0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u26a0.png
--------------------------------------------------------------------------------
/icons/emoji_u2753.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u2753.png
--------------------------------------------------------------------------------
/icons/emoji_u2757.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_u2757.png
--------------------------------------------------------------------------------
/icons/emoji_ufe82b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanguokai/Outdated-Doc-Detector/38adc9303946626720f857132c974d814ade959a/icons/emoji_ufe82b.png
--------------------------------------------------------------------------------
/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "__MSG_extName__",
3 | "version": "2.0.0",
4 | "manifest_version": 3,
5 | "description": "__MSG_extDescription__",
6 | "default_locale": "en",
7 | "icons": {
8 | "128": "oudated-128.png"
9 | },
10 | "permissions": [
11 | "storage"
12 | ],
13 | "background": {
14 | "service_worker": "background.js"
15 | },
16 | "action": {
17 | "default_title": "__MSG_extName__",
18 | "default_icon": "oudated-128.png",
19 | "default_popup": "popup.html"
20 | },
21 | "content_scripts": [
22 | {
23 | "matches": [
24 | "*://developer.mozilla.org/*",
25 | "*://developer.android.com/*",
26 | "*://developer.android.google.cn/*",
27 | "*://firebase.google.com/*",
28 | "*://firebase.google.cn/*",
29 | "*://developers.google.com/*",
30 | "*://developers.google.cn/*",
31 | "*://www.tensorflow.org/*",
32 | "*://tensorflow.google.cn/*",
33 | "*://source.android.com/*",
34 | "*://source.android.google.cn/*",
35 | "*://cloud.google.com/*"
36 | ],
37 | "js": [
38 | "analyzer.js",
39 | "contentScript.js"
40 | ]
41 | }
42 | ],
43 | "options_ui": {
44 | "page": "options.html"
45 | },
46 | "commands": {
47 | "_execute_action": {
48 | "suggested_key": {
49 | "default": "Alt+Shift+E"
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/options.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |