-
Notifications
You must be signed in to change notification settings - Fork 1
/
feedly_function.user.js
161 lines (155 loc) · 4.83 KB
/
feedly_function.user.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// ==UserScript==
// @name Feedly Function
// @version 0.3
// @include http://feedly.com/*
// @include https://feedly.com/*
// @grant GM_registerMenuCommand
// ==/UserScript==
(function() {
var list = [{
name: "清除非無損",
namespace: "_pageid",
func: function() {
var k = [];
for (var j = 0; j < this.entries.length; j++) {
var title = this.entries[j].getTitle().toLowerCase();
if (
(title.indexOf("[eac]") == -1 && title.indexOf("cue") == -1 && title.indexOf("flac") == -1 && title.indexOf("wav") == -1 && title.indexOf("ape") == -1 && title.indexOf("tak") == -1 && title.indexOf("tta") == -1) ||
title.indexOf("同人音") != -1 ||
title.indexOf("東方") != -1 ||
title.match(/\b[Cc]\d{2}\b/) ||
((title.indexOf("快传") != -1 || title.indexOf("快傳") != -1) && title.indexOf("度娘") == -1 && title.indexOf("百度") == -1 && title.indexOf("度盘") == -1 && title.indexOf("度盤") == -1)
) k.push(this.entries[j].getId());
}
this.reader.askMarkEntriesAsRead(k, function() {}, function(i) {
console.log("Error:" + i);
});
}
}, {
name: "只保留'画像','ラブライブ'",
namespace: "_pageid",
func: function() {
var k = [];
for (var j = 0; j < this.entries.length; j++) {
var title = this.entries[j].getTitle().toLowerCase();
if (
/*title.match(/[[「『【〔].+[]」』】〕]\d+話/) ||*/
(title.indexOf("画像") == -1 && title.indexOf("ラブライブ") == -1)
)
k.push(this.entries[j].getId());
}
this.reader.askMarkEntriesAsRead(k, function() {}, function(i) {
console.log("Error:" + i);
});
}
}, {
name: "清除熱度較低的一半文章",
namespace: "_pageid",
func: function() {
var k = [];
for (var j = 0; j < this.entries.length; j++) {
var engagement = this.entries[j].jsonInfo.engagement || 0;
k.push(engagement);
}
k = k.sort(function(a, b) {
return a - b;
});
var a = k[Math.floor(k.length * 0.5)];
if (a == 0)
a = 1;
var k = [];
for (var j = 0; j < this.entries.length; j++) {
var engagement = this.entries[j].jsonInfo.engagement || 0;
if (engagement < a)
k.push(this.entries[j].getId());
}
this.reader.askMarkEntriesAsRead(k, function() {}, function(i) {
console.log("Error:" + i);
});
}
}, {
name: "清除0熱度的文章",
namespace: "_pageid",
func: function() {
var k = [];
for (var j = 0; j < this.entries.length; j++) {
var engagement = this.entries[j].jsonInfo.engagement || 0;
if (engagement < 1)
k.push(this.entries[j].getId());
}
this.reader.askMarkEntriesAsRead(k, function() {}, function(i) {
console.log("Error:" + i);
});
}
}, {
name: "移除TAG",
namespace: "_pageid",
func: function() {
var tagname = this.category;
for (var j = 0; j < this.entries.length; j++) {
//this.entries[j].untag(tagname);
this.reader.askUntagEntry(this.entries[j].getId(), tagname);
}
}
}, {
name: "全部設為未讀",
namespace: "_pageid",
func: function() {
for (var j = 0; j < this.entries.length; j++) {
this.reader.askKeepEntryAsUnread(this.entries[j].getId(), function() {}, function(i) {
console.log("Error:" + i);
});
}
}
}, {
name: "未分類移至自定義分類",
namespace: "_pageid",
func: function() {
var page = this;
var name = prompt("請輸入新分類名稱", "New Category");
if (name && name.replace(/\s*/, '') !== "") {
var list = page.reader.listSubscriptions("global.uncategorized"),
length = list.length;
console.log("新分類名稱:", name);
list.forEach(function(sub, i) {
console.log((i + 1) + "/" + length, "Subscription", sub.id);
page.reader.askUpdateSubscription(sub.id, null, [name], ["global.uncategorized"], {}, false, function() {}, function(ex) {
console.log("Error:" + ex);
});
});
console.log("Done.");
}
}
}, {
name: "Debug",
namespace: "_pageid",
func: function() {
console.log(this);
}
}];
var localScript = function(scriptText, args) {
var args = JSON.stringify(args);
if (typeof scriptText == 'function')
scriptText = '(' + scriptText + ')(' + args + ');';
var script = document.createElement('script');
script.type = 'text/javascript';
script.appendChild(document.createTextNode(scriptText));
document.body.appendChild(script);
setTimeout(function() {
script.parentNode.removeChild(script);
}, 1000);
};
var runMenu = function(id) {
localScript(function(args) {
(eval(args.func)).call(streets.object(document.body.getAttribute(args.namespace)));
}, {
namespace: this.namespace,
func: '(' + this.func + ')'
});
};
if (GM_registerMenuCommand && typeof GM_registerMenuCommand === 'function') {
for (var i = 0; i < list.length; i++) {
GM_registerMenuCommand('Feedly Function - ' + list[i].name, runMenu.bind(list[i], i));
}
}
})()