-
Notifications
You must be signed in to change notification settings - Fork 123
/
000-reverseOrderedOpenInLink.uc.js
53 lines (51 loc) · 2.44 KB
/
000-reverseOrderedOpenInLink.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
// ==UserScript==
// @name 000-reverseOrderedOpenInLink.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description When link is opened from tab A, it opens in the Order of tab A3 A2 A1.
// @include main
// @compatibility 60 61 62 63
// @version 2018/09/24 22:00 fix conflict with other eval
// @version 2018/09/23 21:00 fix ver61 and 62
// @version 2018/09/23 16:00
// ==/UserScript==
(function() {
let func = gBrowser.addTab.toString();
if (Services.appinfo.version.split(".")[0] >= 63) {
if (!/000-bulkOrderedOpenInLink/.test(func)) {
func = func.replace('let tabAfter = this.tabs.item(index);',
`$&
if (openerTab) {
tabAfter = this.selectedTab.nextSibling;
if (this.selectedTab.pinned) {
tabAfter = this.tabs[this._numPinnedTabs];/*000-bulkOrderedOpenInLink*/
}
}`
);
eval("gBrowser.addTab = function " + func.replace(/^function/, ''));
}
}
if (Services.appinfo.version.split(".")[0] <= 60) {
func = gBrowser.addTab.toString();
if (!/000-bulkOrderedOpenInLink/.test(func)) {
func = func.replace('let lastRelatedTab = this._lastRelatedTabMap.get(openerTab);',
`let lastRelatedTab = openerTab;
if (this.selectedTab.pinned) {
lastRelatedTab = this.tabs[this._numPinnedTabs -1];/*000-bulkOrderedOpenInLink*/
}`
);
eval("gBrowser.addTab = function " + func.replace(/^function/, ''));
}
}
if (Services.appinfo.version.split(".")[0] == 61 || Services.appinfo.version.split(".")[0] == 62) {
func = gBrowser.addTab.toString();
if (!/000-bulkOrderedOpenInLink/.test(func)) {
func = func.replace('let lastRelatedTab = openerTab && this._lastRelatedTabMap.get(openerTab);',
`let lastRelatedTab = openerTab;
if (this.selectedTab.pinned) {
lastRelatedTab = this.tabs[this._numPinnedTabs -1];/*000-bulkOrderedOpenInLink*/
}`
);
eval("gBrowser.addTab = function " + func.replace(/^function/, ''));
}
}
})();