PK 9chrome.manifestcontent breadcrumb content/ locale breadcrumb en-US locale/en-US/ skin breadcrumb classic/1.0 skin/ overlay chrome://browser/content/browser.xul chrome://breadcrumb/content/overlay.xul PK 9content/PK 9ab content/overlay.js/* * breadcrumb firefox extension * Copyright (c) 2008 Nicholas Ortenzio * nicholas.ortenzio@gmail.com * http://breadcrumb.downwith.us * * MIT License [http://www.opensource.org/licenses/mit-license.php] * */ var breadcrumb = { getClickMode : function(){ var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); var clickmode = prefs.getIntPref("extensions.breadcrumb.clickmode"); return clickmode; }, onLoad : function(){ this.initialized = true; var urlbar = document.getElementById('urlbar'); urlbar.addEventListener('click', breadcrumb.onSingleClick, true); urlbar.addEventListener('dblclick', breadcrumb.onDoubleClick, true); }, onSingleClick : function(e){ if (breadcrumb.getClickMode() == 1){ var url = breadcrumb.onActivated(e.target); breadcrumb.doRedirect(url); } }, onDoubleClick : function(e){ if (breadcrumb.getClickMode() == 2){ var url = breadcrumb.onActivated(e.target); breadcrumb.doRedirect(url); } }, onActivated : function(bar){ var redirectURL = ''; var url = bar.value; var omega = bar.selectionEnd; //This checks to see if we are at the last section of a URL or not //It is true if we are not if(url.substring(omega-1).indexOf('/')>0){ //This sets our url to the point up to the last '/' redirectURL = url.substring(0,omega+1+url.substring(omega).indexOf('/')); // If our redirectURL = 'http:/' or 'https:/' don't do anything if ((redirectURL == "http:/") || (redirectURL == "https:/")) { return null; } //Check and see if are redirectURL is a subdomain var sub = /(.*)\.(.*)\.(.*)/ var match = sub.exec(redirectURL); // If a subdomain portion of a url was clicked (sub.domain.com) if (match){ // Ignore a www subdomain if(match[1].indexOf('www')<0){ // If there was no more to the url than sub.domain.com, then we forward to www. // other wise we goto the root of the subdomain // ex: // http://sub.domain.com/hello.html => http://sub.domain.com // http://sub.domain.com/ => http://www.domain.com if(redirectURL.length>=url.length){ // make sure we remember if we're dealing with http or https var htype = /(https|http)/ var hmatch = htype.exec(match[1]); // replace with http or https if (hmatch[1]){ redirectURL = url.replace(match[1], hmatch[1]+'://www'); } } return redirectURL } if(redirectURL.length0){ return null; }else{ // if we got the full url and it has a query string value in it, // get rid of it and goto the regular page // ex: // http://sub.domain.com/hello.html?y=1234 => http://sub.domain.com/hello.html if(url.indexOf('?')){ redirectURL = url.substring(0,url.indexOf('?')); return redirectURL; } } // if none of these conditions are met, i have no idea... // do nothing i guess. return null; } }, doRedirect : function(url){ // If we recieved a non-null URL do a redirect if (url){ gBrowser.loadURI(url) } } } window.addEventListener("load", function(e) {breadcrumb.onLoad(e);}, false);PK !90>>content/overlay.xul