Skip to content

Commit

Permalink
v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Chef5 committed Nov 23, 2021
1 parent 3cb423a commit 7518882
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@
"domain": "link.zhihu.com",
"exactMatch": "",
"targetKey": "target",
},
}
```

- name: 站点名称
- domain: 站点域名
- exactMatch: 精确校验url(少数网站中转域名和主站点域名是一样的,例如”简书“,这时候就需要更精确的url匹配了)
- targetKey: 目标url字段

## 安装
## 安装包

https://cloud.189.cn/web/share?code=MnQzamjQ732a(访问码:q6sa)

## 从商店安装

- Chrome: https://chrome.google.com/webstore/detail/continue-to-visit/nabahgobhkeppllhmnkplegdfkehliab
- Firefox: https://addons.mozilla.org/zh-CN/firefox/addon/continue-to-visit/
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Continue To Visit",
"version": "1.0.1",
"manifest_version": 2,
"version": "1.0.2",
"manifest_version": 3,
"description": "常用网址访问外链时,跳过提示页继续访问!",
"content_scripts": [
{
Expand Down
31 changes: 21 additions & 10 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
* @Author: Patrick-Jun
* @Date: 2021-01-31 19:21:01
* @Last Modified by: Patrick-Jun
* @Last Modified time: 2021-08-12 10:52:09
* @Last Modified time: 2021-11-22 23:10:09
*/

"use strict";
// 校验网址更新频率
const updateHours = 24;
// 需要校验的网址配置
const websites = getWebsites() || [
{
Expand Down Expand Up @@ -108,20 +110,29 @@ function getTargetUrl(fullUrl, matchParams) {
* @returns {*} 网站列表
*/
function getWebsites() {
const websitesText = localStorage.getItem('__chrome_ctv_websites');
let websites = [];
try {
websites = JSON.parse(websitesText);
chrome.storage.local.get(['__chrome_ctv_websites'], (result) => {
websites = JSON.parse(result['__chrome_ctv_websites']);
});
} catch (error) {
websites = [];
}
get('https://raw.githubusercontent.com/Patrick-Jun/Chrome-ContinueToVisit/main/src/websites.json', function(res) {
if (res) {
localStorage.setItem('__chrome_ctv_websites', JSON.stringify(res));
} else {
localStorage.setItem('__chrome_ctv_websites', JSON.stringify([]));
}
});
// 从github更新website
try {
chrome.storage.local.get(['__chrome_ctv_update'], (result) => {
const now = (new Date()).getTime();
const update = result['__chrome_ctv_update'];
if (!update || now - update > updateHours * 3600000) {
get('http://v1.hot.isdz.cn/github/Chrome-ContinueToVisit/main/src/websites.json', (res) => {
chrome.storage.local.set({ '__chrome_ctv_websites': JSON.stringify(res || []) });
chrome.storage.local.set({ '__chrome_ctv_update': now });
});
}
});
} catch (error) {
console.error(error);
}
return websites && websites.length > 0 ? websites : null;
}

Expand Down
6 changes: 6 additions & 0 deletions src/websites.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,11 @@
"domain": "link.juejin.cn",
"exactMatch": "",
"targetKey": "target"
},
{
"name": "微信开放社区",
"domain": "developers.weixin.qq.com",
"exactMatch": "developers.weixin.qq.com/community/middlepage/href",
"targetKey": "href"
}
]

0 comments on commit 7518882

Please sign in to comment.