-
Notifications
You must be signed in to change notification settings - Fork 27
/
privateWindowHomepage.uc.js
52 lines (51 loc) · 2.69 KB
/
privateWindowHomepage.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
// ==UserScript==
// @name Private Window Homepage
// @version 1.1.0
// @author aminomancer
// @homepage https://github.com/aminomancer/uc.css.js
// @description By default, private windows are opened to <about:privatebrowsing>, regardless of your homepage or new tab page preferences. Once the window is opened, opening a new tab goes to your new tab page, and pressing the home button goes to your actual home page. But the first tab of a private window is always opened to about:privatebrowsing. This behavior is coded right into `OpenBrowserWindow()` but we can change it. This script simply removes the part of the function that manually sets the URL to about:privatebrowsing. So private windows will now behave like ordinary windows in this (and only this) respect.
// @downloadURL https://cdn.jsdelivr.net/gh/aminomancer/uc.css.js@master/JS/privateWindowHomepage.uc.js
// @updateURL https://cdn.jsdelivr.net/gh/aminomancer/uc.css.js@master/JS/privateWindowHomepage.uc.js
// @license This Source Code Form is subject to the terms of the Creative Commons Attribution-NonCommercial-ShareAlike International License, v. 4.0. If a copy of the CC BY-NC-SA 4.0 was not distributed with this file, You can obtain one at http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
// ==/UserScript==
(function () {
const lazy = {};
XPCOMUtils.defineLazyServiceGetters(lazy, {
BrowserHandler: ["@mozilla.org/browser/clh;1", "nsIBrowserHandler"],
});
ChromeUtils.defineESModuleGetters(lazy, {
HomePage: "resource:///modules/HomePage.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
});
function init() {
if (BrowserWindowTracker.og_openWindow) {
return;
}
BrowserWindowTracker.og_openWindow = BrowserWindowTracker.openWindow;
eval(
`BrowserWindowTracker.openWindow = function ${BrowserWindowTracker.openWindow
.toSource()
.replace(/^\(/, "")
.replace(/\)$/, "")
.replace(/^function[^\S\r\n]*/, "")
.replace(
/\N*\s*if \(\!args && \!lazy\.PrivateBrowsingUtils\.permanentPrivateBrowsing\) {(?:\n\s*\/\/.*)*\s*loadURIString \= \"about\:privatebrowsing\"\;\s*\}/gm,
""
)}`
);
}
if (gBrowserInit.delayedStartupFinished) {
init();
} else {
let delayedListener = (subject, topic) => {
if (topic == "browser-delayed-startup-finished" && subject == window) {
Services.obs.removeObserver(delayedListener, topic);
init();
}
};
Services.obs.addObserver(
delayedListener,
"browser-delayed-startup-finished"
);
}
})();