Skip to content

Commit

Permalink
0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
easychen committed Feb 8, 2023
1 parent d5feb55 commit bc0a653
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
31 changes: 25 additions & 6 deletions extension/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,13 @@ export async function upload_cookie( payload )
}
const domains = payload['domains']?.trim().length > 0 ? payload['domains']?.trim().split("\n") : [];

const cookies = await get_cookie_by_domains( domains );
const local_storages = await get_local_storage_by_domains( domains );
const blacklist = payload['blacklist']?.trim().length > 0 ? payload['blacklist']?.trim().split("\n") : [];

const cookies = await get_cookie_by_domains( domains, blacklist );
const with_storage = payload['with_storage'] || 0;
const local_storages = with_storage ? await get_local_storage_by_domains( domains ) : {};


// 用aes对cookie进行加密
const the_key = CryptoJS.MD5(payload['uuid']+'-'+payload['password']).toString().substring(0,16);
const data_to_encrypt = JSON.stringify({"cookie_data":cookies,"local_storage_data":local_storages});
Expand Down Expand Up @@ -295,7 +300,7 @@ export async function get_local_storage_by_domains( domains = [] )
return ret_storage;
}

async function get_cookie_by_domains( domains = [] )
async function get_cookie_by_domains( domains = [], blacklist = [] )
{
let ret_cookies = {};
// 获取cookie
Expand Down Expand Up @@ -326,11 +331,25 @@ async function get_cookie_by_domains( domains = [] )
// console.log("the cookie", cookie);
if( cookie.domain )
{
if( !ret_cookies[cookie.domain] )

let in_blacklist = false;
for( const black of blacklist )
{
if( cookie.domain.includes(black) )
{
console.log("blacklist 匹配", cookie.domain, black);
in_blacklist = true;
}
}

if( !in_blacklist )
{
ret_cookies[cookie.domain] = [];
if( !ret_cookies[cookie.domain] )
{
ret_cookies[cookie.domain] = [];
}
ret_cookies[cookie.domain].push( cookie );
}
ret_cookies[cookie.domain].push( cookie );
}

}
Expand Down
2 changes: 1 addition & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cookie-cloud",
"displayName": "CookieCloud",
"description": "__MSG_appDesc__",
"version": "0.1.8",
"version": "0.2.1",
"default_locale": "zh_CN",
"author": "easychen@gmail.com",
"license": "GPLv3",
Expand Down
17 changes: 16 additions & 1 deletion extension/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { RadioChangeEvent } from 'antd';
import { Radio } from 'antd';

function IndexPopup() {
let init: Object={"endpoint":"http://127.0.0.1:8088","password":"","interval":10,"domains":"","uuid":String(short_uid.generate()),"type":"up","keep_live":""};
let init: Object={"endpoint":"http://127.0.0.1:8088","password":"","interval":10,"domains":"","uuid":String(short_uid.generate()),"type":"up","keep_live":"","with_storage":1,"blacklist":"google.com"};
const [data, setData] = useState(init);

async function test(action='测试')
Expand Down Expand Up @@ -121,9 +121,24 @@ function IndexPopup() {
</div>
<div className="">同步时间间隔·分钟</div>
<input type="number" className="border-1 my-2 p-2 rounded w-full" placeholder="最少10分钟" value={data['interval']} onChange={e=>onChange('interval',e)} />

{data['type'] && data['type'] == 'up' && <>
<div className="">是否同步Local Storage</div>
<div className="my-2">
<Radio.Group onChange={e=>onChange('with_storage',e)} value={data['with_storage']}>
<Radio value={1}></Radio>
<Radio value={0}></Radio>
</Radio.Group>
</div>

<div className="">同步域名关键词·选填</div>
<textarea className="border-1 my-2 p-2 rounded w-full" style={{"height":"60px"}} placeholder="一行一个,同步包含关键词的全部域名,如qq.com,jd.com会包含全部子域名,留空默认同步全部" onChange={e=>onChange('domains',e)} value={data['domains']}/>

<div className="">同步域名黑名单·选填</div>
<textarea className="border-1 my-2 p-2 rounded w-full" style={{"height":"60px"}} placeholder="黑名单仅在同步域名关键词为空时生效。一行一个域名,匹配则不参与同步" onChange={e=>onChange('blacklist',e)} value={data['blacklist']}/>



<div className="">Cookie保活·选填</div>
<textarea className="border-1 my-2 p-2 rounded w-full" style={{"height":"60px"}} placeholder="定时后台刷新URL,模拟用户活跃。一行一个URL,默认60分钟,可用 URL|分钟数 的方式指定刷新时间" onChange={e=>onChange('keep_live',e)} value={data['keep_live']}/>
</>}
Expand Down

0 comments on commit bc0a653

Please sign in to comment.