-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
40 additions
and
111 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
* | ||
* The Initial Developer of the Original Code is | ||
* Ben Basson <[email protected]> | ||
* Portions created by the Initial Developer are Copyright (C) 2005 | ||
* Portions created by the Initial Developer are Copyright (C) 2015 | ||
* the Initial Developer. All Rights Reserved. | ||
* | ||
* Contributor(s): | ||
|
@@ -35,40 +35,31 @@ | |
* | ||
* ***** END LICENSE BLOCK ***** */ | ||
|
||
var newtabhomepage = { | ||
const gprefs = require("sdk/preferences/service"); | ||
const newtaburl = require('resource:///modules/NewTabURL.jsm').NewTabURL; | ||
|
||
init: function () | ||
{ | ||
gBrowser.removeEventListener("NewTab", BrowserOpenTab, false); | ||
window.BrowserOpenTab = newtabhomepage.opentab; | ||
|
||
// explicitly add new listener | ||
gBrowser.addEventListener("NewTab", newtabhomepage.opentab, false); | ||
|
||
newtabhomepage.prefs = Components.classes['@mozilla.org/preferences-service;1'] | ||
.getService(Components.interfaces.nsIPrefService); | ||
}, | ||
|
||
opentab: function (aEvent) | ||
{ | ||
// Firefox allows multiple piped homepages, take the first if necessary | ||
var homepage = gHomeButton.getHomePage().split("|")[0]; | ||
var newtab = gBrowser.addTab(homepage); | ||
if (newtabhomepage.prefs.getBoolPref("newtabhomepage.selectnewtab")) | ||
{ | ||
gBrowser.selectedTab = newtab; | ||
if (gURLBar) | ||
setTimeout(function() { | ||
// if page is about:blank select() works just like focus, two birds one stone | ||
gURLBar.select(); | ||
}, 0); | ||
} | ||
if (aEvent) | ||
aEvent.stopPropagation(); | ||
|
||
return newtab; | ||
} | ||
// access global startup prefs | ||
var { PrefsTarget } = require("sdk/preferences/event-target"); | ||
var target = PrefsTarget({ branchName: "browser.startup."}); | ||
|
||
} | ||
// set the newtab url preference on startup / install / enable / upgrade | ||
exports.main = function (options, callbacks) { | ||
overrideNewTabPage(); | ||
}; | ||
|
||
// if the homepage is changed, set the new override | ||
target.on("homepage", function () { | ||
overrideNewTabPage(); | ||
}); | ||
|
||
window.addEventListener("load",newtabhomepage.init,false); | ||
// if the add-on is unloaded, revert the override | ||
exports.onUnload = function (reason) { | ||
newtaburl.reset(); | ||
}; | ||
|
||
// overrides the new tab to the (first) homepage | ||
function overrideNewTabPage() { | ||
// Firefox allows multiple piped homepages, take the first if necessary | ||
var homepage = gprefs.getLocalized("browser.startup.homepage", "about:home").split("|")[0]; | ||
newtaburl.override(homepage); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"id": "{66E978CD-981F-47DF-AC42-E3CF417C1467}", | ||
"title": "New Tab Homepage", | ||
"name": "newtabhomepage", | ||
"version": "0.5.0", | ||
"description": "Loads your homepage when you open a new tab.", | ||
"homepage": "http://www.basson.at/firefox-addons/newtabhomepage", | ||
"author": "Ben Basson", | ||
"engines": { | ||
"firefox": ">=41.0a2" | ||
}, | ||
"license": "MPL", | ||
"main": "index.js" | ||
} |