-
Notifications
You must be signed in to change notification settings - Fork 190
/
autoLaunchReader.uc.js
536 lines (444 loc) · 23.3 KB
/
autoLaunchReader.uc.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
// ==UserScript==
// @name autoLaunchReader.uc.js
// @description 自动启用 小说阅读脚本 或 Evernote clearly 或 Readability
// @author ywzhaiqi
// @namespace [email protected]
// @include main
// @charset UTF-8
// @version 2014.6.1
// @homepageURL https://github.com/ywzhaiqi/userChromeJS/tree/master/autoLaunchReader
// @note 2014/06/01 修正新版 Clearly 调用的问题
// @note 2014/05/21 ver0.007 增加 iReader 的支持(可能部分网站会有问题)
// @note 2013/06/06 ver0.004 调用小说脚本失败后,再次调用其它工具。clearly 后台加载网页的支持
// @note 2013/06/04 ver0.003 修复诸多bug
// @note 2013/06/03 ver0.002 改用 Overlay
// @note 2013/06/02 ver0.001 js创建按钮
// ==/UserScript==
if (typeof window.autoReader != "undefined") {
window.autoReader.uninit();
delete window.autoReader;
}
(function(css) {
// 按钮鼠标中键点击自定义
var middleButtonClicked = function(){
};
// var readers = [
// { name: "Clearly",
// isExist: function() {
// return !!window.__readable_by_evernote;
// },
// iloaded: false,
// launch: function(doc) {
// __readable_by_evernote__launch(doc);
// },
// },
// { name: "iReader",
// isExist: function() {
// return !! (window.ya && W);
// },
// iloaded: true,
// launch: function(doc) {
// ya && ya(doc) && xa[doc.uuid] && W.tabs.sendRequest(doc, {
// action: "toggleReader",
// pageHTML: wa,
// settings: Ga(),
// favIconUrl: null
// })
// }
// },
// { name: "Clearly",
// }
// ];
var AUTO_SITE_TEXT = "";
var AUTO_START = true;
var BUTTON_ID = "autoReaderButton";
var DEBUG = false;
let { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
if (!window.Services) Cu.import("resource://gre/modules/Services.jsm");
var ns = window.autoReader = {
auto_sites_reg: [],
get prefs() {
delete ns.prefs;
return ns.prefs = Services.prefs.getBranch("autoReader.");
},
get AUTO_START() AUTO_START,
set AUTO_START(bool) {
updateIcon();
return AUTO_START = !! bool;
},
get AUTO_SITE_TEXT() AUTO_SITE_TEXT,
set AUTO_SITE_TEXT(text) {
ns.handleAutoSiteText(text);
AUTO_SITE_TEXT = text;
},
init: function() {
ns.style = addStyle(css);
// addon-bar, urlbar-icons, nav-bar, PersonalToolbar
ns.makeIcon("addon-bar");
// 载入设置
["AUTO_START"].forEach(function(name) {
try{
ns[name] = ns.prefs.getBoolPref(name);
}catch(e) {}
}, ns);
["AUTO_SITE_TEXT"].forEach(function(name) {
try{
ns[name] = ns.prefs.getCharPref(name);
}catch(e) {}
}, ns);
gBrowser.mPanelContainer.addEventListener('DOMContentLoaded', this, true);
// gBrowser.mPanelContainer.addEventListener('load', this, true);
window.addEventListener('unload', this, false);
},
uninit: function() {
ns.style.parentNode.removeChild(ns.style);
ns.icon.parentNode.removeChild(ns.icon);
gBrowser.mPanelContainer.removeEventListener('DOMContentLoaded', this, true);
// gBrowser.mPanelContainer.removeEventListener('load', this, true);
window.removeEventListener('unload', this, false);
["AUTO_START"].forEach(function(name) {
try {
ns.prefs.setBoolPref(name, ns[name]);
} catch (e) {}
}, ns);
["AUTO_SITE_TEXT"].forEach(function(name) {
try {
ns.prefs.setCharPref(name, ns[name]);
} catch (e) {}
}, ns);
},
handleEvent: function(event) {
switch (event.type) {
case "DOMContentLoaded":
if (this.AUTO_START && event.originalTarget instanceof HTMLDocument) {
var win = event.originalTarget.defaultView;
if (win.frameElement) {
return;
}
this.autoLaunch(win);
}
break;
case "load":
// if (this.AUTO_START && event.originalTarget instanceof HTMLDocument) {
// var win = event.originalTarget.defaultView;
// if (win.frameElement) {
// return;
// }
// this.autoLaunch(win);
// }
break;
case "unload":
this.uninit(event);
break;
}
},
makeIcon: function(_toolbarId) {
var _toolbar = $(_toolbarId);
if(!_toolbar){
throw("autoLaunchReader.uc.js 工具栏ID 不存在");
}
ns.icon = _toolbar.appendChild($C("toolbarbutton", {
id: BUTTON_ID,
class: "toolbarbutton-1",
type: "context",
removable: "true",
state: ns.AUTO_START ? "on" : "off",
label: "autoReader",
onclick: "autoReader.iconClick(event);",
context: "autoReader-menupopup",
tooltiptext: "左键调用阅读工具,右键弹出菜单",
image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABOUlEQVQ4jZ2TsUrDUBSGvxvzAg7qJA5BdBARI1ishYJ26uZLOBQtUpEMjhUr6KAgqC/gC7ipIKSCoiKOQTI4dnQ1N7kOkpomuZb6w4Fz7v3/w38O9wqlFAAV56UKbABzwBj56ACvQPO6Zd8DCKUUK9uP+4CjEeng3B4uHohyvV0FrgYUA4RAwYyCoPYPMcAQ0DAjKe30jXu+mmGX1m8yZwqKRijlaCglyYhhWRaWZXWbpnmRlONG9JP0RBIjy8fdvHNXy3DNKAi0Q/q+3+MGIM3/00EsijFstzLcviPMr1123eRx+zZI1p9vu7k76KB/upmZU7VnRFI+p7vOVC5+l5ZTJ+JJTJdPl4A2IHQuNPgCZoVSiqnSyQ6wB5gDiOueu3km4u88WThaALaAIjChEX4ALtB8f2h4AN/8SQfIa3maJAAAAABJRU5ErkJggg=="
}));
// ? 用 css 添加图标可能一开始会撑大地址栏
setTimeout(function(icon){
icon.removeAttribute("image");
}, 500, ns.icon);
var xml = '\
<menupopup id="autoReader-menupopup" onpopupshowing="autoReader.onPopupShowing();">\
<menuitem label="启用自动阅读器"\
id="autoReader-AUTOSTART"\
type="checkbox"\
autoCheck="true"\
checked="' + AUTO_START + '"\
oncommand="autoReader.toggle(event);"/>\
<hbox hidden="true">\
<textbox id="autoReader-autosite-textbox" cols="50"/>\
<toolbarbutton id="autoReader-autosite-button"\
class="toolbarbutton-1" tooltiptext="设置是否自动启用"\
oncommand="autoReader.onAutoSiteButtonCommand();"\
image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJdSURBVDjLpZP7S1NhGMf9W7YfogSJboSEUVCY8zJ31trcps6zTI9bLGJpjp1hmkGNxVz4Q6ildtXKXzJNbJRaRmrXoeWx8tJOTWptnrNryre5YCYuI3rh+8vL+/m8PA/PkwIg5X+y5mJWrxfOUBXm91QZM6UluUmthntHqplxUml2lciF6wrmdHriI0Wx3xw2hAediLwZRWRkCPzdDswaSvGqkGCfq8VEUsEyPF1O8Qu3O7A09RbRvjuIttsRbT6HHzebsDjcB4/JgFFlNv9MnkmsEszodIIY7Oaut2OJcSF68Qx8dgv8tmqEL1gQaaARtp5A+N4NzB0lMXxon/uxbI8gIYjB9HytGYuusfiPIQcN71kjgnW6VeFOkgh3XcHLvAwMSDPohOADdYQJdF1FtLMZPmslvhZJk2ahkgRvq4HHUoWHRDqTEDDl2mDkfheiDgt8pw340/EocuClCuFvboQzb0cwIZgki4KhzlaE6w0InipbVzBfqoK/qRH94i0rgokSFeO11iBkp8EdV8cfJo0yD75aE2ZNRvSJ0lZKcBXLaUYmQrCzDT6tDN5SyRqYlWeDLZAg0H4JQ+Jt6M3atNLE10VSwQsN4Z6r0CBwqzXesHmV+BeoyAUri8EyMfi2FowXS5dhd7doo2DVII0V5BAjigP89GEVAtda8b2ehodU4rNaAW+dGfzlFkyo89GTlcrHYCLpKD+V7yeeHNzLjkp24Uu1Ed6G8/F8qjqGRzlbl2H2dzjpMg1KdwsHxOlmJ7GTeZC/nesXbeZ6c9OYnuxUc3fmBuFft/Ff8xMd0s65SXIb/gAAAABJRU5ErkJggg=="\
/>\
</hbox>\
<menuitem id="autoReader-menuitem-preferences" label="设置自动启用的站点"\
oncommand="autoReader.showSettingDialog();" />\
<menuseparator/>\
<menuitem label="Evernote Clearly" oncommand="autoReader.launch_clearly();" />\
<menuitem label="Readability 中文版" oncommand="autoReader.launch_readability_cn();" />\
<menuitem label="小说阅读脚本" oncommand="autoReader.launch_myNovelReader();" />\
<menuitem label="iReader" oncommand="autoReader.launch_iReader();" />\
</menupopup>\
';
var range = document.createRange();
range.selectNodeContents($('mainPopupSet'));
range.collapse(false);
range.insertNode(range.createContextualFragment(xml.replace(/\n|\t/g, '')));
range.detach();
},
handleAutoSiteText: function(text) {
ns.auto_sites_reg = [];
var auto_sites = (text || ns.AUTO_SITE_TEXT).split("\n");
auto_sites.forEach(function(line) {
line = line.trim();
if (line) {
var reg;
if(line.search(/^re;/i) == 0){
reg = new RegExp(line.slice(3), "i");
}else{
reg = wildcardToRegExpStr(line);
}
ns.auto_sites_reg.push(reg);
}
});
},
autoLaunch: function(win) {
var locationHref = win.location.href;
debug("检验地址: " + locationHref);
var sites = this.auto_sites_reg;
for (var i = 0; i < sites.length; i++) {
if (new RegExp(sites[i]).test(locationHref)) {
return this.launch(win);
}
}
},
launch: function(win, timer) {
var isAutoLaunch = false;
if(win){
isAutoLaunch = true;
}else{
// win = getFocusedWindow();
win = content;
}
win.setTimeout(function() {
var wrappedJS = win.wrappedJSObject;
var other_launch = function(){
if (window.__readable_by_evernote) {
if(isAutoLaunch){
__readable_by_evernote__launch(win.document);
// debug("后台加载 __readable_by_evernote__launch")
}else{
__readable_by_evernote.__readable_by_evernote__launch();
}
} else if (window.ya && W) {
if (isAutoLaunch) {
win.addEventListener('load', function(){
win.removeEventListener('load', arguments.callee, false);
win.setTimeout(function(){
autoReader.launch_iReader(win.document);
}, 100)
}, false);
} else {
autoReader.launch_iReader();
}
} else if (wrappedJS.X_readability) {
wrappedJS.X_readability();
} else {
// gBrowser.loadURI(READER_TOOL_URL);
}
};
if (wrappedJS.readx) { // 小说阅读脚本
wrappedJS.readx();
// 如果小说阅读脚本没调用成功,则调用
win.setTimeout(function(){
var bodyName = win.document.body.getAttribute("name");
if(!bodyName || bodyName != "MyNovelReader"){
other_launch();
}
}, 1000);
return;
}else{
other_launch();
}
}, timer || 0);
},
launch_clearly: function(){
document.getElementById("readable_by_evernote__button").doCommand();
},
launch_readability_cn: function(){
if(content.wrappedJSObject.X_readability){
content.wrappedJSObject.X_readability();
}
},
launch_myNovelReader: function(){
if(content.wrappedJSObject.readx){
content.wrappedJSObject.readx();
}
},
launch_iReader: function(doc) {
doc || (doc = gBrowser.selectedBrowser.contentDocument);
ya && ya(doc) && xa[doc.uuid] && W.tabs.sendRequest(doc, {
action: "toggleReader",
pageHTML: wa,
settings: Ga(),
favIconUrl: null
})
},
// launch_readability_online: function(){
// run_readability_online(content.document);
// },
iconClick: function(event){
if (!event || !event.button) {
autoReader.launch();
} else if (event.button == 1) {
middleButtonClicked();
} else if (event.button == 2) {
$("autoReader-menupopup").openPopup(ns.icon);
}
},
toggle: function() {
if (this.AUTO_START) {
this.AUTO_START = false;
updateIcon();
} else {
this.AUTO_START = true;
updateIcon();
}
},
onPopupShowing: function(event) {
var tabWindow;
if (tabWindow = window.gBrowser.selectedTab.linkedBrowser.contentWindow) {
return $('autoReader-autosite-textbox').value = tabWindow.location.href;
}
},
showSettingDialog: function(xulBase64) {
if (!xulBase64) {
xulBase64 = "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjw/eG1sLXN0eWxlc2hlZXQgaHJlZj0iY2hyb21lOi8vZ2xvYmFsL3NraW4vIiB0eXBlPSJ0ZXh0L2NzcyI/Pg0KPHdpbmRvdyB4bWxucz0iaHR0cDovL3d3dy5tb3ppbGxhLm9yZy9rZXltYXN0ZXIvZ2F0ZWtlZXBlci90aGVyZS5pcy5vbmx5Lnh1bCIgDQogICAgd2lkdGg9IjYwMCIgaGVpZ2h0PSI0MDAiICB0aXRsZT0i6K6+572u6Ieq5Yqo5ZCv55So55qE56uZ54K5Ij4NCiAgICA8aGJveCBhbGlnbj0iY2VudGVyIiB0b29sdGlwdGV4dD0i5LiA6KGM5LiA5Liq572R5Z2A77yM5Zue6L2m6ZSu6L6T5YWl57uT5p6c77yM56S65L6L77yaaHR0cDovL3d3dy5jbmJldGEuY29tL2FydGljbGVzLyouaHRtIj4NCiAgICAgICAgPGxhYmVsIHZhbHVlP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IgbmV3VmFsdWUgPSB1cmxzX3RleHRib3gudmFsdWU7DQogICAgICAgICAgICAgICAgaWYobmV3VmFsdWUpew0KICAgICAgICAgICAgICAgICAgICBuZXdWYWx1ZSArPSAiXG4iOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB1cmxzX3RleHRib3gudmFsdWUgPSBuZXdWYWx1ZSArIHVybF90ZXh0Ym94LnZhbHVlOw0KICAgICAgICAgICAgICAgIHVybF90ZXh0Ym94LnZhbHVlID0gIiI7DQogICAgICAgICAgICB9DQogICAgICAgIH0NCg0KICAgICAgICBmdW5jdGlvbiAkKGlkKSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZChpZCk7DQoNCiAgICAgICAgXV0+DQogICAgPC9zY3JpcHQ+DQo8L3dpbmRvdz4=";
}
window.openDialog("data:application/vnd.mozilla.xul+xml;charset=UTF-8;base64," + xulBase64,
"name", "top=" + (window.screenY + 100) + ",left=" + (window.screenX + 50));
},
onAutoSiteButtonCommand: function(event) {
// var blackList, tabWindow;
// blackList = getPref('black_list');
// if (blackList.length > 0) {
// blackList += ', ';
// }
// blackList += blacklistTextbox.value;
// setPref('black_list', blackList);
// menupopup.hidePopup();
return event.stopPropagation();
}
};
ns.init();
function updateIcon() {
var newState = "";
var checkautomenu = $("autoReader-AUTOSTART");
if (ns.AUTO_START == false) {
newState = "off";
checkautomenu.setAttribute("checked", false);
} else {
newState = "on";
checkautomenu.setAttribute("checked", true);
}
ns.icon.setAttribute("state", newState);
}
// 代码来自 __readable_by_evernote.__readable_by_evernote__launch
function __readable_by_evernote__launch(__doc){
var $R = window.__readable_by_evernote;
// current
var __win = __doc.defaultView;
// invalid page?
if (__win && __win.location && __win.location.href && $R.valid_url(__win.location.href)) {}else
{
__win.location = 'chrome://readable-by-evernote/content/blank.html';
return;
}
// inject
$R.inject(__doc);
return;
// 以下是旧版,已失效
var
_d = doc,
_b = _d.getElementsByTagName('body')[0],
_o = _d.getElementById('__readable_extension_definitions'),
_l = _d.createElement('script')
;
// create, if not present
// ======================
if (_o);
else
{
_o = _d.createElement('dl');
_o.setAttribute('style', 'display: none;');
_o.setAttribute('id', '__readable_extension_definitions');
_b.appendChild(_o);
}
// set options
// ===========
var
_options = __readable_by_evernote.__get_saved__options(),
_vars = __readable_by_evernote.__get_saved__vars(),
_translations = __readable_by_evernote.__get_translations(),
__definition_items_html = __readable_by_evernote.__get__stuffAsDefinitionItemsHTML
({
'option': _options,
'var': _vars,
'translation': _translations
})
;
_o.innerHTML = __definition_items_html;
// launch in context
// =================
_l.setAttribute('src', 'chrome://readable-by-evernote/content/js/__bookmarklet_to_inject.js');
_l.className = 'bookmarklet_launch';
_b.appendChild(_l);
// custom events
// =============
__readable_by_evernote.__add_custom_events_handler();
}
function debug() { if(DEBUG) Application.console.log(Array.slice(arguments)); }
function $(id) document.getElementById(id);
function $C(name, attr) {
var el = document.createElement(name);
if (attr) Object.keys(attr).forEach(function(n) el.setAttribute(n, attr[n]));
return el;
}
function addStyle(css) {
var pi = document.createProcessingInstruction(
'xml-stylesheet',
'type="text/css" href="data:text/css;utf-8,' + encodeURIComponent(css) + '"'
);
return document.insertBefore(pi, document.documentElement);
}
function getFocusedWindow() {
var win = document.commandDispatcher.focusedWindow;
return (!win || win == window) ? content : win;
}
function wildcardToRegExpStr(urlstr) {
if (urlstr.source) return urlstr.source;
let reg = urlstr.replace(/[()\[\]{}|+.,^$?\\]/g, "\\$&").replace(/\*+/g, function(str) {
return str === "*" ? ".*" : "[^/]*";
});
return "^" + reg + "$";
}
})('\
#autoReaderButton[state="on"]{\
list-style-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABOUlEQVQ4jZ2TsUrDUBSGvxvzAg7qJA5BdBARI1ishYJ26uZLOBQtUpEMjhUr6KAgqC/gC7ipIKSCoiKOQTI4dnQ1N7kOkpomuZb6w4Fz7v3/w38O9wqlFAAV56UKbABzwBj56ACvQPO6Zd8DCKUUK9uP+4CjEeng3B4uHohyvV0FrgYUA4RAwYyCoPYPMcAQ0DAjKe30jXu+mmGX1m8yZwqKRijlaCglyYhhWRaWZXWbpnmRlONG9JP0RBIjy8fdvHNXy3DNKAi0Q/q+3+MGIM3/00EsijFstzLcviPMr1123eRx+zZI1p9vu7k76KB/upmZU7VnRFI+p7vOVC5+l5ZTJ+JJTJdPl4A2IHQuNPgCZoVSiqnSyQ6wB5gDiOueu3km4u88WThaALaAIjChEX4ALtB8f2h4AN/8SQfIa3maJAAAAABJRU5ErkJggg==);\
}\
#autoReaderButton[state="off"]{\
list-style-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABH0lEQVQ4jZ2TTU7DMBSEv2dyBlghFt4jJFggegROAklp07RSDlAJoSYNJRQuwg342YDEOossWPYKFcjdNLSJEwqMNJKfPfPm2ZLFGAPAKIpPgTZwAOxQjxnwDgwH/eAZQIwxjKLxJRA2mBpgwkE/uJJl8sPfzAB8AccOiPsPM8AWEDjAYfWkH/iWOoqTuiYthcg2IpS4hNYarfWqaVUnsqs2zXnmtr/X99PUOncEsTYL5HlemgagqlcIWKyYCpx7F5ZW2e5yQpzcrE1ja9XP9nJ9dzuxtApk9vsWVHSSKYS3qn98na7uX1Ov8VXiJD0BnmqiNmEO7Kte13sRCAU+696jgXOBTq/rZVJ852QyPQJ8oAXsNaR+AI/A0O+4GcAC/tBIHXgDrRwAAAAASUVORK5CYII=);\
}\
');
(function(){
function updateToolbar() {
var toolbars = document.querySelectorAll("toolbar");
Array.slice(toolbars).forEach(function(toolbar) {
var currentset = toolbar.getAttribute("currentset");
if (currentset.split(",").indexOf("autoReaderButton") < 0) return;
toolbar.currentSet = currentset;
try {
BrowserToolboxCustomizeDone(true);
} catch (ex) {}
});
}
updateToolbar();
})();