-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbank.gs
65 lines (56 loc) · 2.21 KB
/
bank.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
60
61
62
63
64
65
// --- Settings --- //
var BankList_Own = []
var BankList_Url = "https://raw.githubusercontent.com/HeiTang/MailCat/main/bank_list.json";
var BankRule_Url = "https://raw.githubusercontent.com/HeiTang/MailCat/main/bank_rule.json";
// --- Settings --- //
// 0. Initial
var BankList_JSON = GetJSON(BankList_Url); // 1-取得銀行資料 JSON
var BankRule_JSON = GetJSON(BankRule_Url);
// 1. MailLabelManage
function Bank_Label(){
for (var bankIndex = 0; bankIndex < BankList_Own.length; bankIndex++) {
// 01. BankListLabel
var isImportant = [0, 0, 0];
var data_type = 1;
var index = BankList_Own[bankIndex];
var bank_label_name = BankList_JSON[index]['label_name'];
var bank_email = BankList_JSON[index]['email'];
// 檢查&建立標籤
CheckLabel(bank_label_name);
// 銀行信件標記
MarkLabel(bank_label_name, bank_email, data_type, isImportant[bankIndex]);
// 02. BankRuleLabel // 0.登入通知 1.交易通知 2.電子帳單
var isImportant = [0, 0, 1];
data_type = 2;
for (var ruleIndex = 0; ruleIndex < BankRule_JSON.length; ruleIndex++) {
var label_name = BankRule_JSON[ruleIndex]['label_name'];
var bank_rule = [Utilities.formatString("label:%s %s", bank_label_name , BankRule_JSON[ruleIndex]['rule'])];
// 檢查&建立標籤
CheckLabel(label_name);
// 特定信件標記
MarkLabel(label_name, bank_rule, data_type, isImportant[ruleIndex]);
}
}
}
// 2. 定時刪除信件(登入通知)
function Bank_AutoRemove(){
var delete_days = [7];
var label_name = [BankRule_JSON[0]['label_name']];
for (var i = 0; i < label_name.length; i++) {
AutoRemove(delete_days[i], label_name[i]);
}
}
// 3. 自動封存信件(登入通知、交易通知)
function Bank_AutoArchive(){
var label_name = [BankRule_JSON[0]['label_name'], BankRule_JSON[1]['label_name']];
for (var i = 0; i < label_name.length; i++) {
AutoArchive(label_name[i]);
}
}
// 4. 備份附件(電子帳單)
function Bank_AutoSave(){
var folder_name = '銀行電子帳單';
var label_name = BankRule_JSON[2]['label_name'];
var rule = Utilities.formatString("has:attachment is:important label:%s", label_name);
AutoSave(folder_name, label_name, rule);
}