Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
benbasson committed Jan 29, 2013
0 parents commit ca29d2b
Show file tree
Hide file tree
Showing 7 changed files with 637 additions and 0 deletions.
469 changes: 469 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
New Tab Homepage
================
Loads your homepage when you open a new tab.

Details
-------
You can customise this extension to load the new tab in the background by typing "about:config" into the location bar, finding the "newtabhomepage.selectnewtab" preference and double-clicking it. By default, the extension follows Firefox's behaviour and opens new tabs in the foreground.

Installation
------------
Drag and drop the latest XPI file from the build folder into a Firefox window. Alternatively, you can install the extension from:

- https://addons.mozilla.org/en-US/firefox/addon/new-tab-homepage
- http://www.cusser.net/extensions/tabhomepage/

Authors
-------
- Ben Basson *@ben_basson*
2 changes: 2 additions & 0 deletions src/chrome.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
overlay chrome://browser/content/browser.xul chrome://tabhomepage/content/tabhomepage.xul
content tabhomepage chrome/content/
74 changes: 74 additions & 0 deletions src/chrome/content/tabhomepage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is New Tab Homepage.
*
* The Initial Developer of the Original Code is
* Ben Basson <[email protected]>
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ben Basson <[email protected]>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */

var newtabhomepage = {

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;
}

}

window.addEventListener("load",newtabhomepage.init,false);
47 changes: 47 additions & 0 deletions src/chrome/content/tabhomepage.xul
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is New Tab Homepage.
The Initial Developer of the Original Code is
Ben Basson <[email protected]>
Portions created by the Initial Developer are Copyright (C) 2005
the Initial Developer. All Rights Reserved.
Contributor(s):
Ben Basson <[email protected]>
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
***** END LICENSE BLOCK ***** -->

<overlay id="tabhomepageOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:nc="http://home.netscape.com/NC-rdf#">

<script type="application/x-javascript"
src="chrome://tabhomepage/content/tabhomepage.js"/>

</overlay>
2 changes: 2 additions & 0 deletions src/defaults/preferences/tabhomepage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Focus newly created tabs */
pref("newtabhomepage.selectnewtab", true);
25 changes: 25 additions & 0 deletions src/install.rdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">

<Description about="urn:mozilla:install-manifest">

<em:id>{66E978CD-981F-47DF-AC42-E3CF417C1467}</em:id>
<em:version>0.4.3</em:version>
<em:name>New Tab Homepage</em:name>
<em:description>Loads your homepage when you open a new tab.</em:description>
<em:creator>Ben Basson</em:creator>
<em:homepageURL>http://www.cusser.net</em:homepageURL>

<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>3.0b2</em:minVersion>
<em:maxVersion>18.0.*</em:maxVersion>
</Description>
</em:targetApplication>

</Description>

</RDF>

0 comments on commit ca29d2b

Please sign in to comment.