Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions extension/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ export async function upload_cookie( payload )

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 ) : {};
const storage_domains = payload['storage_domains']?.trim().length > 0 ? payload['storage_domains']?.trim().split("\n") : [];
const local_storages = with_storage ? await get_local_storage_by_domains( storage_domains, blacklist ) : {};

let headers = { 'Content-Type': 'application/json', 'Content-Encoding': 'gzip' }
// 添加鉴权的 header
Expand Down Expand Up @@ -310,7 +311,7 @@ function cookie_decrypt( uuid, encrypted, password )
return parsed;
}

export async function get_local_storage_by_domains( domains = [] )
export async function get_local_storage_by_domains( domains = [], blacklist = [] )
{
let ret_storage = {};
const local_storages = await browser_load_all('LS-');
Expand All @@ -327,6 +328,20 @@ export async function get_local_storage_by_domains( domains = [] )
}
}
}
} else ret_storage = local_storages;
if( Array.isArray(blacklist) && blacklist.length > 0 )
{
for( const domain of blacklist )
{
for( const key in ret_storage )
{
if( key.indexOf(domain) >= 0 )
{
console.log( "storage blacklist 匹配", domain, key );
delete ret_storage[key];
}
}
}
}
return ret_storage;
}
Expand Down
3 changes: 3 additions & 0 deletions extension/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
"no": {
"message": "No"
},
"syncStorageDomainKeyword": {
"message": "Sync Storage Domain Keyword · Optional"
},
"requestHeader": {
"message": "Request Header · Optional"
},
Expand Down
4 changes: 4 additions & 0 deletions extension/locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
{
"message":"否"
},
"syncStorageDomainKeyword":
{
"message":"同步Storage域名关键词·选填"
},
"requestHeader":
{
"message":"请求Header·选填"
Expand Down
6 changes: 5 additions & 1 deletion extension/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { load_data, save_data } from './function';
import browser from 'webextension-polyfill';

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":"","with_storage":1,"blacklist":"google.com", "headers": "","expire_minutes":60*24*365};
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,"storage_domains":"", "blacklist":"google.com", "headers": "","expire_minutes":60*24*365};
const [data, setData] = useState(init);

async function test(action=browser.i18n.getMessage('test'))
Expand Down Expand Up @@ -145,6 +146,9 @@ function IndexPopup() {
<label className="mr-2"><input type="radio" name="with_storage" value="0" checked={data['with_storage'] == 0} onChange={e=>onChange('with_storage',e)} /> {browser.i18n.getMessage('no')}</label>
</div>

<div className="">{browser.i18n.getMessage('syncStorageDomainKeyword')}</div>
<textarea className="border-1 my-2 p-2 rounded w-full" style={{"height":"60px"}} placeholder={browser.i18n.getMessage('syncDomainKeywordPlaceholder')} onChange={e=>onChange('storage_domains',e)} value={data['storage_domains']}/>

<div className="">{browser.i18n.getMessage('requestHeader')}</div>
<textarea className="border-1 my-2 p-2 rounded w-full" style={{"height":"60px"}} placeholder={browser.i18n.getMessage('requestHeaderPlaceholder')} onChange={e=>onChange('headers',e)} value={data['headers']}/>

Expand Down