PK8EVEVchrome/tabmixplus.jarPK 8content/PK 8content/tabmixplus/PK t5pHEEcontent/tabmixplus/about.xul %aboutDTD; %miscDTD; ]> PK 8content/tabmixplus/bookmarks/PK |p8ff)content/tabmixplus/bookmarks/bookmarks.jsvar Click2TabLoadBookmark = { init : function () { TMP_Bookmark.init(); eval("BookmarksMenu.loadBookmark = " + BookmarksMenu.loadBookmark.toString().replace( 'var browserTarget = whereToOpenLink(aEvent);', 'var browserTarget = whereToOpenLinkTabmix(aEvent, prefStringTMBookmark, selection, aDS);' )); } } // this code is call from browser window and from bookmark manager var TMP_Bookmark = { init : function () { BookmarksCommand.openGroupBookmark = this.TMP_openGroupBookmark; eval("BookmarksCommand.createContextMenu ="+BookmarksCommand.createContextMenu.toString().replace( 'popup.firstChild.setAttribute("default", "true");', '$& \ TMP_Bookmark.buildContextMenu(popup)' )); TMP_update_whereToOpen(); }, buildContextMenu : function (popup) { var _open = popup.getElementsByAttribute("command", "cmd_bm_open")[0]; var _openInWindow = popup.getElementsByAttribute("command", "cmd_bm_openinnewwindow")[0]; var _openInTab = popup.getElementsByAttribute("command", "cmd_bm_openinnewtab")[0]; TMP_updateContextMenu(_open, _openInWindow, _openInTab, prefStringTMBookmark); }, TMP_openGroupBookmark: function (aURI, aTargetBrowser) { var resource = RDF.GetResource(aURI); var urlArc = RDF.GetResource(NC_NS_TM+"URL"); // gNC_NS isn't for 1.0.7 RDFC.Init(BMDS, resource); var containerChildren = RDFC.GetElements(); var res, target, bmGroup = []; while (containerChildren.hasMoreElements()) { res = containerChildren.getNext().QueryInterface(kRDFRSCIID); target = BMDS.GetTarget(res, urlArc, true); if (target) bmGroup.push(target.QueryInterface(kRDFLITIID).Value); } // If the bookmark group was completely invalid, just bail. if (bmGroup.length != 0) { if ("_confirmOpenTabs" in this && !this._confirmOpenTabs(bmGroup.length)) return; var browserWindow = getTopWin(); if (!browserWindow) window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", bmGroup.join("|")); else browserWindow.TMP_Bookmark.openGroup(bmGroup); } }, // fixed: reuse all blank tab not just in the end // fixed: if "browser.tabs.loadFolderAndReplace" is true don't reuse locked and protected tabs open bookmark after those tabs // fixed: focus the first tab if "extensions.tabmix.openTabNext" is true // fixed: remove "selected" and "flst_id" from reuse tab openGroup: function (bmGroup, aWhere) { var browser = getBrowser(); var tabs = browser.mTabContainer.childNodes; var doReplace = aWhere == "tab" ? false : gPref.getBoolPref("browser.tabs.loadFolderAndReplace"); var loadInBackground = aWhere == "tabshifted" ? true : gPref.getBoolPref("browser.tabs.loadBookmarksInBackground"); var openTabNext = gPref.getBoolPref("extensions.tabmix.openTabNext"); // catch tab for reuse var aTab, reuseTabs = [], removeTabs = [], i; var tabIsBlank, canReplace; for (i = 0; i < tabs.length ; i++) { aTab = tabs[i]; tabIsBlank = browser.isBlankNotBusyTab(aTab); canReplace = (doReplace && !aTab.hasAttribute("locked")) || tabIsBlank; if (reuseTabs.length < bmGroup.length && canReplace) reuseTabs.push(aTab); else if ((doReplace && !aTab.hasAttribute("locked") && !aTab.hasAttribute("protected")) || tabIsBlank) removeTabs.push(aTab); } var tabToSelect = null; var prevTab = (!doReplace && openTabNext && browser.mCurrentTab._tPos < tabs.length - 1) ? browser.mCurrentTab : browser.mTabContainer.lastChild; var tabPos, index; for (i = 0; i < bmGroup.length ; i++) { try { // bug 300911 if (i < reuseTabs.length) { aTab = reuseTabs[i]; browser.getBrowserForTab(aTab).loadURI(bmGroup[i]); // reset selected & flst_id attribute if (aTab != browser.mCurrentTab) { aTab.removeAttribute("selected"); aTab.removeAttribute("flst_id"); } else aTab.setAttribute("reloadcurrent", true); } else aTab = browser.addTab(bmGroup[i]); } catch (er) { } if (!tabToSelect) tabToSelect = aTab; // move tab to place index = prevTab._tPos + 1; tabPos = aTab._tPos < index ? index - 1 : index; browser.TMmoveTabTo(aTab, tabPos); prevTab = aTab; } browser.mTabContainer.nextTab = 1; // focus the first tab if prefs say to if (!loadInBackground || doReplace) { // Select the first tab in the group. // Set newly selected tab after quick timeout, otherwise hideous focus problems // can occur because new presshell is not ready to handle events function selectNewForegroundTab(browser, tab) { var old = browser.selectedTab; browser.selectedTab = tab; var reloadCurrent = old.hasAttribute("reloadcurrent"); if (reloadCurrent) old.removeAttribute("reloadcurrent"); if (reloadCurrent && old != tab) { old.removeAttribute("selected"); old.removeAttribute("flst_id"); } } setTimeout(selectNewForegroundTab, 0, browser, tabToSelect); } // Close any remaining open tabs or blank tabs that are left over. while (removeTabs.length > 0) { browser.removeTab(removeTabs.pop()); } // and focus the content content.focus(); }, _getBookmarkTitle: function (url) { if(! BMSVC || ! BMDS || ! RDF) return null; var urlArc = RDF.GetResource(NC_NS_TM+"URL"); var urlLiteral = RDF.GetLiteral(url); if (BMDS.hasArcIn(urlLiteral, urlArc)) { var bmResources, bmResource, title, type, ptype; bmResources = BMSVC.GetSources(urlArc, urlLiteral, true); while (bmResources.hasMoreElements()) { bmResource = bmResources.getNext(); type = BookmarksUtils.resolveType(bmResource); if (type != "ImmutableBookmark") { ptype = BookmarksUtils.resolveType(BMSVC.getParent(bmResource)); if ( (type == "Bookmark" || type == "IEFavorite") && ptype != "Livemark") { title = BookmarksUtils.getProperty(bmResource, NC_NS_TM+"Name"); if (title != "") return title; } } } } return null; } } PK T6/5-*content/tabmixplus/bookmarks/bookmarks.xul PK T6mxx1content/tabmixplus/bookmarks/bookmarksManager.xul PK 1T6[U//.content/tabmixplus/bookmarks/bookmarksPanel.jsvar BookmarksTreeClick2Tab = { bookmarksView : null, init : function () { window.removeEventListener('load', function () { BookmarksTreeClick2Tab.init(); }, false); if (typeof(PlacesController) == "function") { TMP_Places.init(); return; } TMP_Bookmark.init(); this.bookmarksView = document.getElementById("bookmarks-view"); eval("this.bookmarksView.openItemClick = " + this.bookmarksView.openItemClick.toString().replace( 'var browserTarget = whereToOpenLink(aEvent);', 'var browserTarget = whereToOpenLinkTabmix(aEvent, prefStringTMBookmark, selection, this.db);' )); eval("this.bookmarksView.openItemKey = " + this.bookmarksView.openItemKey.toString().replace( 'BookmarksCommand.openBookmark(this._selection, "current", this.db)', '{var browserTarget = whereToOpenLinkTabmix(null, prefStringTMBookmark, this._selection, this.db); BookmarksCommand.openBookmark(this._selection, browserTarget, this.db);}' )); } } PK 8content/tabmixplus/click/PK 87++!content/tabmixplus/click/click.jsvar onDoubleClick = false; var gTab; // single click function // function TM_checkClick (event) { if (event && event.button == 2) return; // right click if (event && event.button == 0 && event.detail > 1) return; // double click (with left button) var target = event.originalTarget; // don't do anything if user click on close tab button , or on any other button on tab or tabbar if (target.getAttribute("anonid") == "tmp-close-button" || target.localName == "toolbarbutton") return; // the fix for bug 216899 will make autoscrolling override contentLoadURL if both are enabled // we don't need autoscrolling to override contentLoadURL if user click on tab or tabbar if (event.button == 1 && gPref.getBoolPref("middlemouse.contentLoadURL")) { if (!event.getPreventDefault()) { middleMousePaste(event); event.stopPropagation(); } return; } onDoubleClick = false; var aTab = target; while ( aTab.localName != "tabs" ) { if ( aTab.localName == "tab" ) break; if ( aTab.parentNode ) aTab = aTab.parentNode; else return; } gTab = aTab; var clickOutTabs = aTab.localName == "tabs"; // for tab flip if ( !clickOutTabs && event.button == 0 && aTab.hasAttribute("clickOnCurrent") ) { aTab.removeAttribute("clickOnCurrent"); var tabFlip = TMP_getBoolPref(tabxBranch, "tabFlip", false); var tabFlipDelay = TMP_getIntPref (tabxBranch, "tabFlipDelay", 250); if (tabFlip && !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey){ window.setTimeout(function () { if (!onDoubleClick) { gBrowser.previousTab(aTab); gBrowser.stopMouseHoverSelect(aTab); content.focus(); } }, tabFlipDelay ); return; } } var prefName /* middle click*/ if (event.button == 1) prefName = "middle" /* shift click*/ else if (event.button == 0 && event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey) prefName = "shift" /* alt click*/ else if (event.button == 0 && event.altKey && !event.ctrlKey && !event.shiftKey && !event.metaKey) prefName = "alt" /* ctrl click*/ else if (event.button == 0 && (event.ctrlKey && !event.metaKey || !event.ctrlKey && event.metaKey) && !event.shiftKey && !event.altKey) prefName = "ctrl" TMclickAction(prefName, clickOutTabs, aTab); } // Double click function // function TM_onTabBarDblClick (e) { if ( !e || e.button != 0 || e.ctrlKey || e.shiftKey || e.altKey || e.metaKey ) return; onDoubleClick = true; var aTab = e.originalTarget; // don't do anything if user click on close tab button , or on any other button on tab or tabbar if (aTab.getAttribute("anonid") == "tmp-close-button" || aTab.localName == "toolbarbutton") return; while ( aTab.localName != "tabs" ) { if ( aTab.localName == "tab" ) break; aTab = aTab.parentNode; } // check if the 2 click was not on the same tab // it's look like only problem in 1.0.7 if (gTab != aTab) { gTab = aTab; return; } else gTab = null; TMclickAction( "dbl", aTab.localName == "tabs", aTab ); } // call action function from click on tabs or tabbar // function TMclickAction ( pref, clickOutTabs, aTab ) { if (!pref) return; // just in case we missed something var defaultPref = {middleClickTab:2, middleClickTabbar:10, shiftClickTab:5, shiftClickTabbar:0, altClickTab:6, altClickTabbar:0, ctrlClickTab:22, ctrlClickTabbar:0, dblClickTab:0, dblClickTabbar:1}; pref += clickOutTabs ? "ClickTabbar" : "ClickTab"; var action = TMP_getIntPref (tabxBranch, pref , defaultPref[pref]); content.focus(); switch ( action ) { case 0 : break; case 1 : BrowserOpenTab(); break; case 2 : // removeTab tab after delay, // if the tab is in the middle of selecting or we just add new tab // it can caused problem function _delayCloseTab(b, tab){ b.closeTab(tab); } if (aTab.localName != "tab") aTab = gBrowser.mCurrentTab; setTimeout(_delayCloseTab, 0, gBrowser, aTab); break; case 3 : gBrowser.duplicateTab(aTab); break; case 4 : gBrowser.reloadTab(aTab); break; case 5 : gBrowser.protectTab(aTab); break; case 6 : gBrowser.lockTab(aTab); break; case 7 : gBrowser.reloadAllTabs(aTab); break; case 8: gBrowser.removeAllTabsBut(aTab); break; case 9: gBrowser.closeAllTabs(); break; case 10: TMP_ClosedTabs.undoCloseTab(); break; case 11: gBrowser.renameTab(aTab); break; case 12: //taken from tco if (SessionSaver && SessionSaver.snapBackTab) SessionSaver.snapBackTab(SessionSaver.snapback_noFX, SessionSaver.snapback_willFocus); break; case 13: gBrowser.undoRemoveAllTab(); break; case 14: gBrowser.duplicateInWindow(aTab, false); break; case 15: gBrowser.freezeTab(aTab); break; case 16: gBrowser.reloadAllTabsBut(aTab); break; case 17: gBrowser.closeLeftTabs(aTab); break; case 18: gBrowser.closeRightTabs(aTab); break; case 19: gBrowser.reloadLeftTabs(aTab); break; case 20: gBrowser.reloadRightTabs(aTab); break; case 21: // taken from tco if (aTab.localName != "tab") aTab = gBrowser.mCurrentTab; var href; if (window.IeView && window.IeView.ieViewLaunch) { href = gBrowser.getBrowserForTab(aTab).currentURI.spec; IeView.ieViewLaunch("Internet Explorer.lnk", href); } else if (window.gIeTab && window.gIeTab.switchTabEngine) { if (gBrowser.selectedTab != aTab) gBrowser.selectedTab = aTab; gIeTab.switchTabEngine(aTab, gIeTab.getBoolPref("ietab.alwaysNewTab", false)); } else if(window.ieview && window.ieview.launch) { href = gBrowser.getBrowserForTab(aTab).currentURI.spec; ieview.launch(href); } break; case 22: gBrowser.SelectToMerge(aTab); break; case 23: dtMergeWindows.mergeWindows(); break; case 24: gBrowser.closeGroupTabs(aTab); break; case 25: if (aTab.localName != "tab") aTab = gBrowser.mCurrentTab; var browserSpecs = gBrowser.getBrowserForTab(aTab).webNavigation; if (gIsPlaces) PlacesCommandHook.bookmarkPage(aTab.linkedBrowser, PlacesUtils.bookmarksMenuFolderId, true); else addBookmarkForBrowser(gBrowser.getBrowserForTab(aTab).webNavigation); break; case 26: if (document.getElementById('Browser:BookmarkAllTabs')) { if (gIsPlaces) PlacesCommandHook.bookmarkCurrentPages(); else addBookmarkForTabBrowser(gBrowser, true); } break; case 27: gBrowser.duplicateInWindow(aTab, true); break; case 28: gBrowser.copyTabUrl(aTab); break; } } function Tm_checkTabClick(event) { var tabContextMenu = window.gBrowser.mStrip.firstChild.nextSibling; // Undo close tab Commands - firefox 3.0 toggle this menu item also when submneu are show var undoClose = tabxPrefs.getBoolPref("undoClose"); TMP_showItem("context_undoCloseTab", tabxPrefs.getBoolPref("undoCloseTabMenu") && undoClose); if (event.originalTarget != tabContextMenu) return true; var item; if (document.popupNode.parentNode) item = document.popupNode.parentNode.parentNode.id; if (item && (item == "btn_tabslist" || item == "btn_tabslistSorted")) gBrowser.mContextTab = document.popupNode.tab; var clickOutTabs = gBrowser.mContextTab ? gBrowser.mContextTab.localName == "tabs": true; var aTab = clickOutTabs ? gBrowser.mCurrentTab : gBrowser.mContextTab; var cIndex = aTab._tPos; var isOneWindow = numberOfWindows() == 1; var newTab = document.getElementById("context_newTab"); TMP_showItem(newTab, tabxPrefs.getBoolPref("newTabMenu")); if (clickOutTabs) { TMP_setItem(newTab, "label", newTab.getAttribute("_newtab")); TMP_setItem(newTab, "oncommand", "TMP_BrowserOpenTab();"); } else { TMP_setItem(newTab, "label", newTab.getAttribute("_newtab") + " " + newTab.getAttribute("_afterthis")); TMP_setItem(newTab, "oncommand", "var tabbrowser = this.parentNode.parentNode.parentNode.parentNode; TMP_BrowserOpenTab(tabbrowser.mContextTab);"); } // Duplicate Commands TMP_showItem("tm-duplicateTab", tabxPrefs.getBoolPref("duplicateMenu")); TMP_showItem("tm-duplicateinWin", tabxPrefs.getBoolPref("duplicateinWinMenu") && !gSingleWindowMode); TMP_showItem("tm-detachTab", tabxPrefs.getBoolPref("detachTabMenu") && !gSingleWindowMode); TMP_showItem("tm-mergeWindowsTab", tabxPrefs.getBoolPref("showMergeWindow") && (!gSingleWindowMode || (gSingleWindowMode && !isOneWindow))); var showRenameTabMenu = tabxPrefs.getBoolPref("renameTabMenu"); TMP_showItem("tm-renameTab", showRenameTabMenu); TMP_showItem("tm-copyTabUrl", tabxPrefs.getBoolPref("copyTabUrlMenu")); // ---------------- menuseparator ---------------- // // Reload Commands TMP_showItem("context_reloadTab", tabxPrefs.getBoolPref("reloadTabMenu")); TMP_showItem("context_reloadAllTabs", tabxPrefs.getBoolPref("reloadAllMenu")); TMP_showItem("tm-autoreloadTab_menu", tabxPrefs.getBoolPref("autoReloadMenu")); TMP_showItem("tm-reloadRight", tabxPrefs.getBoolPref("reloadRightMenu")); TMP_showItem("tm-reloadLeft", tabxPrefs.getBoolPref("reloadLeftMenu")); TMP_showItem("tm-reloadOther", tabxPrefs.getBoolPref("reloadOtherMenu")); // ---------------- menuseparator ---------------- // TMP_showItem("tm-undoCloseList", tabxPrefs.getBoolPref("undoCloseListMenu") && undoClose); // ---------------- menuseparator ---------------- // // Close tab Commands TMP_showItem("context_closeTab", tabxPrefs.getBoolPref("closeTabMenu")); TMP_showItem("tm-closeAllTabs", tabxPrefs.getBoolPref("closeAllMenu")); TMP_showItem("tm-closeSimilar", tabxPrefs.getBoolPref("closeSimilarTabs")); TMP_showItem("context_closeOtherTabs", tabxPrefs.getBoolPref("closeOtherMenu")); TMP_showItem("tm-closeLeftTabs", tabxPrefs.getBoolPref("closeLeftMenu")); TMP_showItem("tm-closeRightTabs", tabxPrefs.getBoolPref("closeRightMenu")); // ---------------- menuseparator ---------------- // TMP_showItem("tm-docShell", tabxPrefs.getBoolPref("docShellMenu")); TMP_showItem("tm-freezeTab", tabxPrefs.getBoolPref("freezeTabMenu")); TMP_showItem("tm-protectTab", tabxPrefs.getBoolPref("protectTabMenu")); TMP_showItem("tm-lockTab", tabxPrefs.getBoolPref("lockTabMenu")); // ---------------- menuseparator ---------------- // TMP_showItem("context_bookmarkTab", tabxPrefs.getBoolPref("bookmarkTabMenu")); TMP_showItem("context_bookmarkAllTabs", tabxPrefs.getBoolPref("bookmarkTabsMenu")); // we call this again by popupshown to make sure we don't show 2 menuseparator together TMP_tabContextMenuShown(event); if (showRenameTabMenu) { // disabled rename if the title not ready yet var titleNotReady; if (aTab.hasAttribute("busy")) { var browser = gBrowser.getBrowserForTab(aTab); var url = browser.contentDocument.baseURI || browser.currentURI.spec; var docTitle = getTitleFromBookmark(url, browser.contentDocument.title); if (!docTitle || docTitle == gBrowser.mStringBundle.getString("tabs.untitled")) titleNotReady = true; } TMP_setItem("tm-renameTab", "disabled", titleNotReady); } var protectedTab = aTab.hasAttribute("protected"); var keepLastTab = tabxPrefs.getBoolPref("keepLastTab"); var lockedTab = aTab.hasAttribute("locked"); var tabsCount = gBrowser.mTabContainer.childNodes.length; var tabBarCollapsed = tabsCount == 1 && gPref.getBoolPref("browser.tabs.autoHide"); TMP_setItem("context_closeTab", "disabled", protectedTab || keepLastTab || tabBarCollapsed); TMP_setItem("tm-closeAllTabs", "disabled", tabsCount == 1 && (keepLastTab || tabBarCollapsed)); TMP_setItem("context_closeOtherTabs", "disabled", tabsCount == 1); var closeTabsEmpty = gBrowser.closedTabs.length < 1; TMP_setItem("context_undoCloseTab", "disabled", closeTabsEmpty); TMP_setItem("tm-undoCloseList", "disabled", closeTabsEmpty); TMP_setItem("tm-mergeWindowsTab", "disabled", isOneWindow); TMP_setItem("tm-closeRightTabs", "disabled", cIndex == tabsCount - 1); TMP_setItem("tm-closeLeftTabs", "disabled", cIndex == 0); TMP_setItem("tm-reloadRight", "disabled", cIndex == tabsCount - 1); TMP_setItem("tm-reloadLeft", "disabled", cIndex == 0); TMP_setItem("tm-reloadOther", "disabled", tabsCount == 1); TMP_setItem("tm-docShell", "disabled", clickOutTabs); var freezeTabMenu = document.getElementById("tm-freezeTab"); if ( !freezeTabMenu.hidden ) TMP_setItem(freezeTabMenu, "checked", lockedTab && protectedTab); var lockTabMenu = document.getElementById("tm-lockTab"); if ( !lockTabMenu.hidden ) TMP_setItem(lockTabMenu, "checked", lockedTab); var protectTabMenu = document.getElementById("tm-protectTab"); if ( !protectTabMenu.hidden ) TMP_setItem(protectTabMenu, "checked", protectedTab); onAutoReloadPopup(false, aTab); return true; } // don't show 2 menuseparator together // this function is call by "popupshown" event // this is only to the case that other extensions popupshowing run after our Tm_checkTabClick function TMP_tabContextMenuShown(event) { var tabContextMenu = window.gBrowser.mStrip.firstChild.nextSibling; if (event.originalTarget != tabContextMenu) return; // don't show 2 menuseparator together var hideNextSeparator = true, lastVisible, hideMenu = true; for(var mi = tabContextMenu.firstChild; mi; mi = mi.nextSibling) { if (mi.localName == "menuseparator") { mi.hidden = hideNextSeparator; if (!hideNextSeparator) { hideNextSeparator = true; lastVisible = mi; } } else if(!mi.hidden && !mi.collapsed) { hideNextSeparator = false; hideMenu = false; } } // hide the last visible menuseparator if it is the last visible in the menu if (hideNextSeparator && lastVisible) lastVisible.hidden = true; // if all the menu are hidden don't show the popup if (hideMenu) tabContextMenu.hidePopup(); } function TM_checkContentMenu () { try { var showFreezeTab = gPref.getBoolPref("extensions.tabmix.freezeTabContent"); var showLockTab = gPref.getBoolPref("extensions.tabmix.lockTabContent"); var showProtectTab = gPref.getBoolPref("extensions.tabmix.protectTabContent"); var showTabsList = gPref.getBoolPref("extensions.tabmix.tabsList"); var showCloseTab = gPref.getBoolPref("extensions.tabmix.closeTabContent"); var showUndoCloseTab = gPref.getBoolPref("extensions.tabmix.undoCloseTabContent"); var showUndoCloseList = gPref.getBoolPref("extensions.tabmix.undoCloseListContent"); var undoClose = gPref.getBoolPref("extensions.tabmix.undoClose"); var showDuplicateTab = gPref.getBoolPref("extensions.tabmix.duplicateTabContent"); var showDuplicateWin = gPref.getBoolPref("extensions.tabmix.duplicateWinContent"); var showDetachTab = gPref.getBoolPref("extensions.tabmix.detachTabContent"); var showLinkWithHist = gPref.getBoolPref("extensions.tabmix.linkWithHistory"); var showMerge = gPref.getBoolPref("extensions.tabmix.mergeWindowContent"); var showOpenHere = gPref.getBoolPref("extensions.tabmix.openLinkHere"); var showInverseLink = gPref.getBoolPref("extensions.tabmix.openInverseLink"); var showAutoReload = gPref.getBoolPref("extensions.tabmix.autoReloadContent"); var bgPref = gPref.getBoolPref("browser.tabs.loadInBackground"); var isOneWindow = numberOfWindows() == 1; } catch(e){} var tabsListMenu = document.getElementById("tm-tabsList"); var closeTabMenu = document.getElementById("tm-content-closetab"); var freezeTabMenu = document.getElementById("tm-content-freezeTab"); var lockTabMenu = document.getElementById("tm-content-lockTab"); var protectTabMenu = document.getElementById("tm-content-protectTab"); var undoCloseTabMenu = document.getElementById("tm-content-undoCloseTab"); var undoCloseListMenu = document.getElementById("tm-content-undoCloseList"); var undoCloseSep = document.getElementById("tm-content-undoCloseSep"); var duplicateTabMenu = document.getElementById("tm-duplicateTabContext"); var duplicateWinMenu = document.getElementById("tm-duplicateinWinContext"); var detachTabMenu = document.getElementById("tm-detachTabContext"); var linkWithHist = document.getElementById("tm-linkWithhistory"); var mergeMenu = document.getElementById("tm-mergeWindows"); var miscSep = document.getElementById("tm-content-miscSep"); var textSep = document.getElementById("tm-content-textSep"); var openHere = document.getElementById("tm-openlinkhere"); var inverseLink = document.getElementById("tm-openinverselink"); var autoReload = document.getElementById("tm-autoreload_menu"); var contentClick = gContextMenu.onTextInput || gContextMenu.onLink || gContextMenu.onImage; var tabsCount = gBrowser.mTabContainer.childNodes.length; var closeTabsEmpty = gBrowser.closedTabs.length < 1; var protectedTab = gBrowser.mCurrentTab.hasAttribute("protected"); var lockedTab = gBrowser.mCurrentTab.hasAttribute("locked"); openHere.hidden = !gContextMenu.onLink || !showOpenHere; inverseLink.hidden = !gContextMenu.onLink || !showInverseLink; if (!inverseLink.hidden){ var focusType = bgPref ? "fg":"bg"; inverseLink.setAttribute("label", inverseLink.getAttribute(focusType+"label")); inverseLink.setAttribute("accesskey", inverseLink.getAttribute(focusType+"accesskey")); } linkWithHist.hidden = !gContextMenu.onLink || !showLinkWithHist; closeTabMenu.hidden = !showCloseTab || contentClick; var keepLastTab = tabxPrefs.getBoolPref("keepLastTab"); var tabBarCollapsed = tabsCount == 1 && gPref.getBoolPref("browser.tabs.autoHide"); closeTabMenu.setAttribute("disabled", protectedTab || keepLastTab || tabBarCollapsed); freezeTabMenu.hidden = !showFreezeTab || contentClick; lockTabMenu.hidden = !showLockTab || contentClick; lockTabMenu.setAttribute("checked", lockedTab); protectTabMenu.hidden = !showProtectTab || contentClick; protectTabMenu.setAttribute("checked", protectedTab); duplicateTabMenu.hidden = !showDuplicateTab || contentClick; detachTabMenu.hidden = !showDetachTab || contentClick || gSingleWindowMode; duplicateWinMenu.hidden = !showDuplicateWin || contentClick || gSingleWindowMode; freezeTabMenu.setAttribute("checked", protectedTab && lockedTab); tabsListMenu.hidden = !showTabsList || contentClick; undoCloseTabMenu.hidden = closeTabsEmpty || !showUndoCloseTab || !undoClose || contentClick; undoCloseListMenu.hidden = closeTabsEmpty || !showUndoCloseList || !undoClose || contentClick; undoCloseSep.hidden = undoCloseTabMenu.hidden && undoCloseListMenu.hidden || gContextMenu.isTextSelected && closeTabMenu.hidden && lockTabMenu.hidden && protectTabMenu.hidden && tabsListMenu.hidden && freezeTabMenu.hidden; mergeMenu.hidden = !showMerge || isOneWindow || contentClick; miscSep.hidden = mergeMenu.hidden && closeTabMenu.hidden && duplicateTabMenu.hidden && duplicateWinMenu.hidden && lockTabMenu.hidden && protectTabMenu.hidden && tabsListMenu.hidden && freezeTabMenu.hidden || gContextMenu.isTextSelected; textSep.hidden = !gContextMenu.isTextSelected || mergeMenu.hidden && duplicateTabMenu.hidden && duplicateWinMenu.hidden && closeTabMenu.hidden && lockTabMenu.hidden && protectTabMenu.hidden && tabsListMenu.hidden && freezeTabMenu.hidden && undoCloseTabMenu.hidden && undoCloseListMenu.hidden; autoReload.hidden = !showAutoReload || contentClick || gContextMenu.isTextSelected; var hideOpenAllLinks = gPref.getBoolPref("extensions.tabmix.openAllLinks") ? openMultipleLinks(true) : true; document.getElementById("tm-openAllLinks").hidden = hideOpenAllLinks; onAutoReloadPopup(true); } function onAutoReloadPopup(currentTab, aTab) { var tab = currentTab ? gBrowser.mCurrentTab : aTab; var id = currentTab ? "tm-autoreload" : "tm-autoreloadTab"; var element = ["1", "2", "3", "4", "5", "6", "7", "8"]; var time = [5, 15, 30, 60, 2*60, 5*60, 15*60, 30*60]; if (tab.autoReloadEnabled == null) gBrowser.setupAutoReload(tab); document.getElementById(id+"_enable").setAttribute("checked", tab.autoReloadEnabled); for(var i=0; i 0) { var range = nsISelectionObject.getRangeAt(0); var treeWalker = window._content.document.createTreeWalker( range.cloneContents(), NodeFilter.SHOW_ELEMENT, myNodeFilter, true); var nextEpisode = treeWalker.nextNode(); var newTab, firstTab, firstUrl; while(nextEpisode != null) { if (nextEpisode.nodeName == "li") nextEpisode = nextEpisode.firstChild; // if(nextEpisode.href && nextEpisode.href.indexOf('http') == 0) { if(nextEpisode.href) { // might change it to only accept certain protocols like it used to if (check) return false; newTab = gBrowser.addTab(nextEpisode.href); if (!firstTab) { firstTab = newTab; firstUrl = nextEpisode.href; gBrowser.TMP_selectNewForegroundTab(firstTab, null, firstUrl); } } nextEpisode = treeWalker.nextNode(); } } return true; } function checkForCtrlClick(aEvent) { var aButton = aEvent.target; if (!aButton.disabled && aEvent.button == 0 && (aEvent.ctrlKey || aEvent.metaKey)) { if (aButton.id == "btn_undoclose") TMP_ClosedTabs.undoCloseTab(); else BrowserCloseTabOrWindow(); aButton.setAttribute("afterctrlclick", true); } } function isAfterCtrlClick(aButton) { if (aButton.getAttribute("afterctrlclick")) { aButton.removeAttribute("afterctrlclick"); if (aButton.hasAttribute("open")) aButton.removeAttribute("open"); return true; } return false; } function createUndoCloseList (popup) { if (isAfterCtrlClick(popup.parentNode)) return false; beforeCommonList(popup); // Grab the list of closed tabs var ctabs = gBrowser.closedTabs; var mi, count; for(var i = ctabs.length - 1; i >= 0; i--) { var tab = ctabs[i]; var tabSH = tab[1]; // Grab the session history for the tab // Grab the title and uri (make the uri friendly text) var title = tab[2]; var uri, _uri = tabSH.getEntryAtIndex(tabSH.index, false).URI; if ( _uri.scheme == "about" && title == "" ) uri = title = "about:blank"; else try { uri = _uri.scheme + ":\/\/" + _uri.hostPort + _uri.path; } catch (e) { uri = title; } var label = title ? title : uri; // Insert a menu item for each closed tab in the cache mi = document.createElement("menuitem"); mi.setAttribute("class", "menuitem-iconic bookmark-item"); mi.setAttribute("statustext", uri) mi.setAttribute("tooltiptext", label); count = (ctabs.length - i) + (ctabs.length - i<10 ? " : " : ": "); mi.setAttribute("label", count + label); if (!uri.match(/^https/)) mi.setAttribute("image", tab[3]); mi.setAttribute("accesskey", "" + (ctabs.length - i)); mi.closeTabIndex = i; if (i == ctabs.length - 1) mi.setAttribute("key", gIsFirefox2 ? "key_undoCloseTab" : "key_tm_undoClose"); popup.appendChild(mi); } var stringBundle = document.getElementById("tmp-string-bundle"); mi = document.createElement("menuseparator"); popup.appendChild(mi); mi = document.createElement("menuitem"); mi.setAttribute("label", stringBundle.getString("undoclosetab.clear.label")); mi.setAttribute("accesskey", stringBundle.getString("undoclosetab.clear.accesskey")); mi.closeTabIndex = -1; popup.appendChild(mi); mi = document.createElement("menuitem"); mi.setAttribute("label", stringBundle.getString("restoreall.label")); mi.setAttribute("accesskey", stringBundle.getString("restoreall.accesskey")); mi.closeTabIndex = -2; popup.appendChild(mi); return true; } function removeCloseTab (event, popup) { if (!tabxPrefs.getBoolPref("middleclickDelete")) return; var index = event.originalTarget.closeTabIndex if (event.button == 1 && index > -1 ){ getClosedTab('delete', index); if (gBrowser.closedTabs.length > 0) createUndoCloseList(popup); else { popup.hidePopup(); if (popup.parentNode.id != "btn_undoclose") popup.parentNode.parentNode.hidePopup(); } } } // sometimes context popup stay "open", we hide it manually. function TM_hidePopup () { var node = document.popupNode; while (node && node.localName != "menubar" && node.localName != "toolbar") { if (node.localName == "menupopup" || node.localName == "popup") { if (node.hasAttribute("open")) node.removeAttribute("open"); node.hidePopup(); } node = node.parentNode; } } // return the indexd tab from the list and remove the tab from the list function getClosedTab(where, index) { var ctabs = gBrowser.closedTabs; var aTab = null; var updateRDF = SessionManager.enableBackup && SessionPref.getBoolPref("save.closedtabs"); if(index >= 0) { TMP_SessionStore.removeClosedTab(ctabs.length - 1 - index); aTab = ctabs.splice(index, 1)[0]; var ord=-1; switch (where) { // xxx need more work on this. when tab added and removed case "current": ord = gBrowser.mCurrentTab._tPos; break; case "tab": if (gPref.getBoolPref("extensions.tabmix.openTabNext")) ord = gBrowser.mCurrentTab._tPos+1; else ord = gBrowser.mTabs.length; break; case "original": ord = aTab[0]; break; default: } // don't change position on delete if (ord > -1 && where != "delete") { for (var i = index; i < ctabs.length; i++){ if (ctabs[i][0] >= ord) ctabs[i][0]++; } if (updateRDF) SessionManager.fixClosedtabTabPos(ord); } } else { if (index == -2) gBrowser.delayUndoRemoveAllTab(); else if (index == -1) { while(ctabs.length > 0) ctabs.pop(); TMP_SessionStore.removeClosedTab(); if (updateRDF) SessionManager.deleteWinClosedtabs(gSessionPath[0] + "/" + gBrowser.windowID); } } if (ctabs.length < 1) TMP_ClosedTabs.setButtonDisableState(true); if (aTab != null && updateRDF) SessionManager.deleteClosedtabAt(index+1); return aTab; } function _restoreTab(where, index) { // call restoreTab after delay to let the popup menu time to hide window.setTimeout( function () { delayRestoreTab(where, index); }, 0 ); } // restore the tab function delayRestoreTab(where, index) { var ord, aTab = getClosedTab(where, index); if (!aTab) return; switch (where) { case "current": var cTab = gBrowser.mCurrentTab; ord = cTab._tPos; cTab.collapsed = true; var restoredTab = gBrowser.restoreTab(ord, aTab[1], aTab[4], aTab[5]); if (restoredTab != cTab) gBrowser.removeTab(cTab); else cTab.collapsed = false; break; case "window": var newWindow = window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no"); newWindow.duplicat = true; newWindow.duplicatData = { scroll: aTab[5], oldHistory: aTab[1], prop: aTab[4] } break; case "tab": if (gPref.getBoolPref("extensions.tabmix.openTabNext")) ord = gBrowser.mCurrentTab._tPos+1; else ord = gBrowser.mTabs.length; gBrowser.restoreTab(ord, aTab[1], aTab[4], aTab[5]); break; case "original": gBrowser.restoreTab(aTab[0], aTab[1], aTab[4], aTab[5]); } } function NW_waitForSessionHistory(event) { //try to set zoom factor befor we load content setTextZoom(getBrowser().selectedBrowser, window.duplicatData.scroll.split(",")[2]) waitForSessionHistory(20); } // wait For sessionHistory in new window function waitForSessionHistory(attempts) { var webNav = gBrowser.webNavigation; try{ webNav.sessionHistory; } // Test if sessionHistory exists yet catch (err) { // webNav.sessionHistory is not yet available, try again later if (attempts) window.setTimeout('waitForSessionHistory(' + --attempts + ')', 50); return; } if ((webNav.sessionHistory == null) && attempts){ window.setTimeout('waitForSessionHistory(' + --attempts + ')', 50); return; } gBrowser.restoreTab(gBrowser.selectedTab._tPos, window.duplicatData.oldHistory, window.duplicatData.prop, window.duplicatData.scroll); delete window.duplicatData; if (window.opener && window.opener.needToClose) setTimeout(function() {window.opener.TMP_BrowserCloseWindow();}, 0); } function closeTabAddBookmarks(currentIndex) { var tabData = gBrowser.closedTabs[currentIndex]; // tabData[1] - history tabData[2] - title var url = tabData[1].getEntryAtIndex(tabData[1].index, false).URI.spec; var title = getTitleFromBookmark(url, tabData[2]); if (gIsPlaces) PlacesCommandHook.bookmarkLink(PlacesUtils.bookmarksMenuFolderId, url, title); else BookmarksUtils.addBookmark(url, title, undefined); } function closeTabcopyTabUrl(currentIndex) { var tab = gBrowser.closedTabs[currentIndex]; var tabSH = tab[1]; // history var URL = tabSH.getEntryAtIndex(tabSH.index, false).URI.spec; var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"] .getService(Components.interfaces.nsIClipboardHelper); clipboard.copyString(URL); } function removeTabFromList (event, popup, aType) { if (!tabxPrefs.getBoolPref("middleclickDelete")) return; if (event.target.id == "btn_tabslistSorted") return; if (event.button == 1) { var aTab = event.originalTarget.tab; if (popup.parentNode.id == "tm-tabsList" && (gBrowser.mCurrentTab == aTab || gBrowser.isBlankTab(gBrowser.mCurrentTab))) { popup.hidePopup(); gBrowser.removeTab(aTab); return; } gBrowser.removeTab(aTab); if (gBrowser.mTabs.length > 0) { createTabsList(popup, aType); var item = popup.parentNode.parentNode; if (item.parentNode.id == "btn_tabslist") createTabsList(item, aType); } else popup.hidePopup(); } } // called from tabmix.xml tabs scroll buttons function _createTabsList (event, side) { event.stopPropagation(); var tablist = document.getElementById("tabslist"); beforeCommonList(tablist); createCommonList(tablist, 2, side); if (tablist.hasChildNodes()) tablist.showPopup(event.target, -1, -1, "popup", "bottomleft","topleft"); } // show sort/unsort tabs list popup after click on sorted tab menu function showTabsListPopup (event) { event.stopPropagation(); setTimeout( function (popup){ popup.showPopup(popup.parentNode, -1, -1, "popup", "bottomleft", "topleft"); }, 0, event.target.parentNode); } function createTabsList (popup, aType) { if (isAfterCtrlClick(popup.parentNode)) return false; // the context menu isn't visible if the strip is collapsed // uncollapsed the stip and collapsed the tabbar instead if (popup.id == "btn_tabslist_menu" && gBrowser.mStrip.collapsed) { var visibility = gBrowser.mTabContainer.collapsed; popup.setAttribute("tabBar_collapsed", visibility); if (!visibility) gBrowser.mTabContainer.collapsed = true; gBrowser.mStrip.collapsed = false; } var tabContextMenu = gBrowser.mStrip.firstChild.nextSibling; if (popup.hasAttribute("contextmenu") && popup.getAttribute("contextmenu") != tabContextMenu.id) popup.setAttribute("contextmenu", tabContextMenu.id); if (gPref.getBoolPref("extensions.tabmix.enableScrollSwitch")) popup.addEventListener("DOMMouseScroll", TMP_tabsListScroll, true); beforeCommonList(popup); createCommonList(popup, aType); return true; } function beforeCommonList(popup) { var item = popup.parentNode; if (item.id == "btn_tabslist" || item.id == "btn_undoclose") item.removeAttribute("tooltiptext"); // clear out the menu popup if we show the popup after middle click while (popup.hasChildNodes()) { var menuItem = popup.firstChild; if (menuItem.id.indexOf("btn_tabslist") != -1) break; popup.removeChild(menuItem); } popup.addEventListener("DOMMenuItemActive", updateMenuItemActive, false); popup.addEventListener("DOMMenuItemInactive", updateMenuItemInactive, false); } function createCommonList (popup, aType, side) { var tabs = new Array(gBrowser.mTabs.length); var i; switch(aType) { case 1: for (i = 0; i < gBrowser.mTabs.length; i++) tabs[i] = new tabSorting(gBrowser.mTabs[i], i); tabs = tabs.sort(); for (i = 0; i < tabs.length; i++) createMenuItems(popup, tabs[i].Tab, tabs[i].Index, aType); break; case 2: for (i = 0; i < gBrowser.mTabs.length; i++) { if (side && side == "left" && !gBrowser.mTabs[i].collapsed) continue; else if (side && side == "right" && (gBrowser.mTabs[i].collapsed || gBrowser.mTabContainer.isTabVisible(gBrowser.mTabs[i]._tPos))) continue; createMenuItems(popup, gBrowser.mTabs[i], i, aType); } break; case 3: for (i = TMP_LastTab.TabHistory.length - 1; i >= 0; i--) createMenuItems(popup, TMP_LastTab.TabHistory[i], i, aType); break; } } function createMenuItems(popup, tab, value, aType) { var count, mi = document.createElement("menuitem"); mi.setAttribute("class", "menuitem-iconic bookmark-item alltabs-item"); mi.setAttribute("statustext", gBrowser.getBrowserForTab(tab).currentURI.spec); mi.setAttribute("tooltiptext", tab.label); count = aType != 3 ? (value + 1) + (value < 9 ? " : " : ": ") : ""; mi.setAttribute("count", count); mi.setAttribute("label", count + tab.label); mi.setAttribute("crop", tab.getAttribute("crop")); mi.setAttribute("image", tab.getAttribute("image")); if (tab.hasAttribute("busy")) mi.setAttribute("busy", tab.getAttribute("busy")); if (tab.selected) mi.setAttribute("selected", "true"); mi.value = value; tab.mCorrespondingMenuitem = mi; tab.addEventListener("DOMAttrModified", TMP_tabOnAttrModified, false); tab.addEventListener("TabClose", TMP_tabOnTabClose, false); mi.tab = tab; if (popup.id == "btn_tabslist_menu") popup.insertBefore(mi, document.getElementById("btn_tabslist_sep")); else popup.appendChild(mi); } function TMP_tabsListScroll(aEvent) { TMtabBarScroll(aEvent); } function TMP_tabOnAttrModified(aEvent) { var menuItem = aEvent.target.mCorrespondingMenuitem; if (menuItem) { var attrName = aEvent.attrName; var count = ""; switch (attrName) { case "label": count = menuItem.getAttribute("count"); case "crop": case "busy": case "image": case "selected": if (aEvent.attrChange == aEvent.REMOVAL) menuItem.removeAttribute(attrName); else menuItem.setAttribute(attrName, count + aEvent.newValue); } } } function TMP_tabOnTabClose(aEvent) { var menuItem = aEvent.target.mCorrespondingMenuitem; if (menuItem && menuItem.parentNode) menuItem.parentNode.removeChild(menuItem); } function TMP_TabsListOncommand(event) { TMP_tabSelectedFromList(event.originalTarget.tab); } function TMP_tabSelectedFromList(aTab) { if (gBrowser.selectedTab == aTab) gBrowser.mTabContainer.ensureTabIsVisible(gBrowser.mTabContainer.selectedIndex); else // if we select another tab _handleTabSelect will call ensureTabIsVisible gBrowser.selectedTab = aTab; } var gBackupLabel = ""; function hideCommonList(popup) { // restore the strip collapsed status if (popup.id == "btn_tabslist_menu" && popup.hasAttribute("tabBar_collapsed")) { gBrowser.mStrip.collapsed = true; var visibility = gBrowser.mTabContainer.collapsed; if (popup.getAttribute("tabBar_collapsed") == "false") gBrowser.mTabContainer.collapsed = false; popup.removeAttribute("tabBar_collapsed"); } // clear out the menu popup and remove the listeners while (popup.hasChildNodes()) { var menuItem = popup.firstChild; if (menuItem.id.indexOf("btn_tabslist") != -1) break; if ("tab" in menuItem) { menuItem.tab.removeEventListener("DOMAttrModified", TMP_tabOnAttrModified, false); menuItem.tab.removeEventListener("TabClose", TMP_tabOnTabClose, false); menuItem.tab.mCorrespondingMenuitem = null; } popup.removeChild(menuItem); } var item = popup.parentNode; if (item.id == "btn_tabslist" || item.id == "btn_undoclose") item.setAttribute('tooltiptext', item.getAttribute('_tooltiptext')); popup.removeEventListener("DOMMenuItemActive", updateMenuItemActive, false); popup.removeEventListener("DOMMenuItemInactive", updateMenuItemInactive, false); popup.removeEventListener("DOMMouseScroll", TMP_tabsListScroll, true); gBackupLabel = ""; } function updateMenuItemActive(event, tab) { var statusTextFld = document.getElementById("statusbar-display"); if (gBackupLabel=="") gBackupLabel = statusTextFld.label; if (!tab) tab = event.target; updateStatusText(tab.getAttribute("statustext")); } function updateMenuItemInactive(event) { updateStatusText(""); } function updateStatusText(itemText) { var statusTextFld = document.getElementById("statusbar-display"); var newText = itemText ? itemText : gBackupLabel; if (newText != statusTextFld.label) statusTextFld.label = newText; } function tabSorting(tab, index) { this.Tab = tab; this.Index = index; } tabSorting.prototype.toString = function() { return this.Tab.label.toLowerCase(); } PK 3+w00 content/tabmixplus/contents.rdf chrome://tabmixplus/content/pref/preferencesOverlay.xul chrome://tabmixplus/content/tabmix.xul chrome://tabmixplus/content/links/links.xul chrome://tabmixplus/content/bookmarks/bookmarks.xul chrome://tabmixplus/content/bookmarks/bookmarksManager.xul chrome://tabmixplus/content/links/links.xul chrome://tabmixplus/content/links/links.xul chrome://tabmixplus/content/history/history-panel.xul PK 8content/tabmixplus/extensions/PK 6O%content/tabmixplus/extensions/sage.js// prevent Sage from load pages in locked tabs // code by onemen const OPEN_TAB_FOR_SAGE = "extensions.tabmix.opentabfor.sage"; var TMP_Sage = { init: function () { eval("updateItemContextMenu ="+updateItemContextMenu.toString().replace( 'readStateController.onCommandUpdate();', '$& TMP_Sage.buildContextMenu();' )); eval("bookmarksTreeClick ="+bookmarksTreeClick.toString().replace( 'const BOOKMARK_SEPARATOR', 'var where = TMP_Places.fixWhereToOpen(aEvent, CreateHTML._tabbed ? "tab" : "current", TMP_Sage.openTabPref); \ CreateHTML.tabbed = where == "tab"; \ $&' )); eval("bookmarksOpen ="+bookmarksOpen.toString().replace( 'getContentBrowser().loadURI(lastResource.url);', 'if (CreateHTML._tabbed) getContentBrowser().addTab(lastResource.url); \ else $&' )); eval("openURI ="+openURI.toString().replace( 'switch (windowType)', 'windowType = TMP_Places.fixWhereToOpen((oType instanceof Event)? oType : null, !windowType ? "current" : windowType, TMP_Sage.openTabPref); \ $&' )); if (typeof(PlacesController) != "function") TMP_Bookmark.init(); window.removeEventListener('load', function () { TMP_Sage.init(); }, false); }, buildContextMenu: function () { var _open = document.getElementById("rssOpenItem"); var _openInWindow = document.getElementById("rssOpenNewWindowItem"); var _openInTab = document.getElementById("rssOpenNewTabItem"); TMP_updateContextMenu(_open, _openInWindow, _openInTab, this.openTabPref); }, get openTabPref() { var prefSVC = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); if (prefSVC.prefHasUserValue(OPEN_TAB_FOR_SAGE)) return OPEN_TAB_FOR_SAGE; else return prefStringTMBookmark; } }PK p6@y&content/tabmixplus/extensions/sage.xul PK [8 (content/tabmixplus/extensions/wizzrss.js// code by onemen // Look for RSS/Atom News Reader function TMP_LookForRSS() { if ("gotoLink" in window) TMP_wizzrss.init(); if ("openNewsfox" in window) TMP_Newsfox.init(); if ("RSSTICKER" in window) TMP_RSSTICKER.init(); } var TMP_RSSTICKER = { init : function () { eval("RSSTICKER.writeFeed ="+RSSTICKER.writeFeed.toString().replace( 'tbb.setAttribute("onclick"', 'tbb.setAttribute("onclick", "this.onClick(event);");\ tbb.setAttribute("_onclick"' ).replace( 'tbb.onContextOpen =', 'tbb.onContextOpen = TMP_RSSTICKER.onContextOpen; \ tbb.onClick = TMP_RSSTICKER.onClick; \ tbb._onContextOpen =' )); }, onClick : function (event) { if (event.ctrlKey) { this.markAsRead(true); } else if ((this.parent.alwaysOpenInNewTab && (event.which == 1)) || (event.which == 2)) { this.onContextOpen("tab"); } else if (event.which == 1) { this.onContextOpen(); } }, onContextOpen : function (target) { if (!target) { if (TMP_whereToOpen(null).lock) this.parent.browser.openInNewTab(this.href); else window._content.document.location.href = this.href; } else if (target == "window") { if (gSingleWindowMode) this.parent.browser.openInNewTab(this.href); else window.open(this.href); } else if (target == "tab") { this.parent.browser.openInNewTab(this.href); } this.markAsRead(); } } // prevent Wizz RSS from load pages in locked tabs var TMP_wizzrss = { init : function () { var codeToReplace = /getContentBrowser\(\).loadURI|contentBrowser.loadURI/; const newCode = "TMP_wizzrss.openURI"; var _functions = ["addFeedbase","validate","gohome","tryagain","promptStuff","promptStuff", "doSearch","viewLog","renderItem","playEnc","renderAllEnc","playAllEnc", "gotoLink","gotoLink","itemLinkClick","itemLinkClick","itemListClick"]; _functions.forEach( function(_function) { if (_function in window) eval("window." + _function + " ="+ window[_function].toString() .replace(codeToReplace,newCode)); } ); }, openURI : function (uri) { var w = Components.classes['@mozilla.org/appshell/window-mediator;1'] .getService(Components.interfaces.nsIWindowMediator) .getMostRecentWindow("navigator:browser"); var tabBrowser = w.getBrowser(); var openNewTab = w.TMP_whereToOpen(true).lock; if (openNewTab) { var newTab = tabBrowser.addTab(uri); var theBGPref = !readPref("WizzRSSFocusTab", false, 2); tabBrowser.TMP_selectNewForegroundTab(newTab, theBGPref); } else tabBrowser.loadURI(uri); } } // prevent Newsfox from load pages in locked tabs var TMP_Newsfox = { init : function () { eval("openNewsfox ="+openNewsfox.toString().replace( 'if (newTab) {', 'newTab = newTab || TMP_whereToOpen(null).lock; \ $&' )); } } PK d6PΎ)content/tabmixplus/extensions/wizzrss.xul PK 8content/tabmixplus/flst/PK a{p8oUzrzrcontent/tabmixplus/flst/flst.js//////////////////////////////////////// // flst.js // Daniel Lindkvist, 04-08-09 // modified by logixoul, 2005-04-18 , modified again by onemen //////////////////////////////////////// var flst = { slideshow: null, //for slideshow showAlert: function(msg) { try { var alerts = Components.classes["@mozilla.org/alerts-service;1"] .getService(Components.interfaces.nsIAlertsService); alerts.showAlertNotification("chrome://tabmixplus/skin/tmp.png", "Tab Mix Plus", msg, false, "", null); } catch (e) { var statusTextFld = document.getElementById("statusbar-display"); statusTextFld.label = msg; setTimeout(function() { statusTextFld.removeAttribute("label"); }, 2500); } }, //toggle flst on/off toggle: function(event) { var msg; var setting = TMP_getIntPref(tabxBranch, "focusTab", 2) var stringBundle = document.getElementById("tmp-string-bundle"); if ( setting != 4 ) { gPref.setIntPref("extensions.tabmix.focusTab",4); msg = stringBundle.getString("flstOn.label"); } else { gPref.setIntPref("extensions.tabmix.focusTab",2); msg = stringBundle.getString("flstOff.label"); } this.showAlert(msg); }, //for slideshow toggleSlideshow: function() { var stringBundle = document.getElementById("tmp-string-bundle"); if(this.slideshow != null) { window.clearInterval(this.slideshow); this.slideshow = null; this.showAlert(stringBundle.getString("slideshowOff.label")); return; } if (gBrowser.mTabContainer.childNodes.length < 2) return; var time = 4; try { time = gPref.getIntPref("extensions.tabmix.slideDelay"); } catch(e){ } time = time * 1000; // to get seconds this.slideshow = window.setInterval(this.focusNext, time); this.showAlert(stringBundle.getString("slideshowOn.label")); }, focusNext: function() { var tabs = gBrowser.mTabContainer.childNodes; if (tabs.length == 1) return; var index = gBrowser.mTabContainer.selectedIndex + 1; if (index == tabs.length) index = 0; gBrowser.selectedTab = tabs[index]; } } /*//////////////////////////////////////////////////////////////////// // The Original Code is the Merge Window function of "Duplicate Tab"// // extension for Mozilla Firefox.// // version 0.5.1// // The Initial Developer of the Original Code is Twanno. // // Modfied for TMP by CPU// *///////////////////////////////////////////////////////////////////// var dtMergeWindows = { // merge several windows to one window, or only selected tabs to previous focussed window, // or only current window with previous window mergeWindows: function() { var mergePopups = gPref.getBoolPref("extensions.tabmix.mergePopups"); var placePopupNextToOpener = gPref.getBoolPref("extensions.tabmix.placePopupNextToOpener"); var mergeAllWindows = gPref.getBoolPref("extensions.tabmix.mergeAllWindows"); var openTabNext = gPref.getBoolPref("extensions.tabmix.openTabNext"); var stringBundle = document.getElementById("tmp-string-bundle"); // other variables used in this function var currentIndex, tabs, browsers = new Array(), i, j; // get browser windows listed and add them to an array var windowsArrayList = dtMergeWindows.listWindows(); var windowsArray = windowsArrayList.windowsArray; var popupsArray = windowsArrayList.popupsArray; var currentWindowIsPopup = windowsArrayList.isCurrentWindowPopup; // force the merging of windows when the current window is a popup // and the popup would be merged with one other (non popup) window var forceMergeWindows = (currentWindowIsPopup && (windowsArray.length == 1 || !mergeAllWindows)); // foreground window is not a popup other window(s) is/are popup(s) var mergeBackGround = (windowsArray.length == 0 && popupsArray.length > 0 && !currentWindowIsPopup && mergePopups); // alert if just one window is open; no need to merge one window if (!forceMergeWindows && ((!mergePopups && windowsArray.length < 1 && !currentWindowIsPopup) || windowsArray.length+popupsArray.length < 1)) { var errorMessage = stringBundle.getString('tmp.merge.error'); const errorimage = "chrome://tabmixplus/skin/tmpsmall.png"; var browser = getBrowser().selectedBrowser; if (getBrowser().showMessage) { getBrowser().showMessage(browser, errorimage, errorMessage, '', null, null, null, "top", true); } else if (getBrowser().getNotificationBox) { var notificationBox = getBrowser().getNotificationBox(browser); if (!notificationBox.getNotificationWithValue("mergeWindows")) { const priority = notificationBox.PRIORITY_INFO_MEDIUM; notificationBox.appendNotification(errorMessage, "mergeWindows", errorimage, priority, null); } } else window.alert(errorMessage); return; } // check if one or more tabs are selected to be merged var selectedTabs = getBrowser().mTabContainer.getElementsByAttribute('mergeselected','true'); var tabsSelected = (selectedTabs.length > 0); // don't merge the current window if it is a popup and all windows are to be merged except popups var dontMergeCurrentWindow = (!forceMergeWindows && !mergePopups && currentWindowIsPopup && mergeAllWindows); // get currently focussed and previously focussed window // and get the window which has been out of focus longest var currentWindow = (dontMergeCurrentWindow)?windowsArray[windowsArray.length-1]:windowsArrayList.currentWindow; var previousWindow = (dontMergeCurrentWindow)?windowsArray[windowsArray.length-2]:windowsArray[windowsArray.length-1]; var firstWindow = windowsArray[0]; if (mergeBackGround) { // to correctly merge popup(s) when only the current window is not a popup currentWindow = popupsArray.pop(); firstWindow = windowsArrayList.currentWindow; previousWindow = windowsArrayList.currentWindow; currentWindowIsPopup = true; windowsArray[0] = windowsArrayList.currentWindow; } var previousWindowTabBar = previousWindow.getBrowser().mTabContainer; var firstWindowTabBar = firstWindow.getBrowser().mTabContainer; var previousWindowTabIndex = (openTabNext)?previousWindowTabBar.selectedIndex:previousWindowTabBar.childNodes.length; var firstWindowTabIndex = (openTabNext)?firstWindowTabBar.selectedIndex:firstWindowTabBar.childNodes.length; // get currently focussed tab, so it can be selected again after merging if (tabsSelected && !gBrowser.mCurrentTab.hasAttribute('mergeselected')) { i = 0, j = -1; while (i < gBrowser.mTabContainer.childNodes.length) { if (gBrowser.mTabContainer.childNodes[i].hasAttribute('mergeselected')) j++; if ((i >= gBrowser.mTabContainer.selectedIndex) && (j > -1)) { currentIndex = j; break; } i++; } } else currentIndex = (tabsSelected)?gBrowser.mTabContainer.selectedIndex:currentWindow.getBrowser().mTabContainer.selectedIndex; // If more then one window is opened and not all windows must be merged to one: // Either because of selected tabs or the pref is set to do so // Merge only the (selected) tabs of the currently focussed window and the previously focussed window if (tabsSelected || !mergeAllWindows) { var openerPosition = -1; tabs = currentWindow.getBrowser().mTabContainer.childNodes; // if tabs have been selected, list them in an array if (tabsSelected && !mergeBackGround) browsers = listTabs(selectedTabs, window); else if (tabsSelected && mergeBackGround) { var previousTabs = previousWindow.getBrowser().mTabContainer.childNodes; browsers = listTabs(tabs, currentWindow); for (i = 0; i < previousTabs.length; i++) { if (!previousTabs[i].hasAttribute('mergeselected')) previousTabs[i].setAttribute('mergeremove', 'true'); } } // if no tabs have been selected, list all tabs of the window in an array else if (!tabsSelected) { browsers = listTabs(tabs, currentWindow); } // if the current window is a popup window place the popup next to its opener // when that opener is found in the previous window. if (currentWindowIsPopup && placePopupNextToOpener) { var openerPositionArray = getPopupOpenerPosition(currentWindow, [previousWindow], previousWindowTabIndex); openerPosition = openerPositionArray[0]; if (openerPositionArray[1] == 'tabs') { currentIndex = (mergeBackGround)? currentIndex: openerPosition + currentIndex; // the popup opener was found in one of the tabs in the window that will remain. // place the tab(s) next to the opener setTabsInBrowser(previousWindow, browsers, openerPosition); } } // place all tabs in one window if (openerPosition == -1) { currentIndex = previousWindowTabIndex + currentIndex; setTabsInBrowser(previousWindow, browsers); } // prompt a warning if some tabs are selected and the window with remaining tabs is closed var promptpref = gPref.getBoolPref("extensions.tabmix.warnOnclose"); var closepref = gPref.getBoolPref("extensions.tabmix.closeOnSelect"); var askForPrompt = ((promptpref) && (tabsSelected) && (selectedTabs.length < tabs.length)); var promptOK = false, promptAgain = { value:true }; if (askForPrompt && closepref) { var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); var promptTitle = stringBundle.getString('tmp.merge.warning.title'); var promptMessage = stringBundle.getString('tmp.merge.warning.message'); var promptCheckboxLabel = stringBundle.getString('tmp.merge.warning.checkboxLabel'); promptOK = promptService.confirmCheck(window, promptTitle, promptMessage, promptCheckboxLabel, promptAgain); } // select the tab which was selected in the top window previousWindowTabBar.selectedIndex = currentIndex; // close current window if all tabs are merged or if specified by user to do so with some tabs selected if ((promptOK || (!askForPrompt)) && closepref) { if (!promptAgain.value) { gPref.setBoolPref("exetnsions.tabmix.warnOnClose", false); } previousWindow.focus(); currentWindow.close(); } // If the window is not to be closed, remove the tabs that have been merged // if tab is protect remove mergeselected attribute else { // xxx if we close in one loop we get //Error: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMXULElement.boxObject] // Source file: chrome://global/content/bindings/browser.xml // we need to fix the flst select after remove and made the proper new tab index in gBrowser.removeTab //in the first loop we remove all the tab but the current tab //in the 2nd loop we remove the current tab for (i = selectedTabs.length - 1; i > -1; --i) { var tab = selectedTabs.item(i); if (tab.hasAttribute("protected")) { tab.removeAttribute("mergeselected"); tab.label = tab.label.substr(4); } else if (tab != currentWindow.getBrowser().mCurrentTab) currentWindow.getBrowser().removeTab(tab); } for (i = selectedTabs.length - 1; i > -1; --i) { tab = selectedTabs.item(i); currentWindow.getBrowser().removeTab(tab); } previousWindow.focus(); } if (mergeBackGround && tabsSelected) { // because the other windows are added to the window with selected tabs, the not selected tabs // have to be removed. (normally the selected tabs will be removed and placed in another window) for (i = 0; i < selectedTabs.length; i++) { selectedTabs.item(i).label = selectedTabs.item(i).label.substr(4); } for (i = 0; i < previousTabs.length; i++) { if (previousTabs[i].hasAttribute('mergeremove')) { if (i < currentIndex) currentIndex--; previousWindow.getBrowser().removeTab(previousTabs[i]); } if (previousTabs[i].hasAttribute('mergeselected')) previousTabs[i].removeAttribute('mergeselected'); previousTabs[i].label = previousTabs[i].label.substr(4); } } previousWindowTabBar.selectedIndex = currentIndex; } // Merge all windows to one window if more then one window is opened and // no tabs are selected and the pref is set to merge all windows. else if (!tabsSelected && mergeAllWindows) { // list all tabs on all windows with history scrollposition var addedTabsLength = 0, popupsList = new Array(); for (i = 1; i < windowsArray.length; i++) { tabs = windowsArray[i].getBrowser().mTabContainer.childNodes; browsers = browsers.concat(listTabs(tabs, windowsArray[i])); // the last window in the array is only the current window if merging of popups is disabled // and the current window is a popup window if (windowsArray[i] != currentWindow) addedTabsLength += tabs.length; } // the current window is a popup and popups should also be merged // or the current window is not a popup if (!dontMergeCurrentWindow) { tabs = currentWindow.getBrowser().mTabContainer.childNodes; if (!currentWindowIsPopup) { browsers = browsers.concat(listTabs(tabs, currentWindow)); currentIndex = firstWindowTabIndex + addedTabsLength + currentIndex; } else { var listedTabs = listTabs(tabs, currentWindow); if (placePopupNextToOpener) { openerPositionArray = getPopupOpenerPosition(currentWindow, windowsArray, firstWindowTabIndex); openerPosition = openerPositionArray[0]; switch (openerPositionArray[1]) { case 'browsers': // the popup opener was found in the list of browsers that will be added to the remaining window. currentIndex = openerPosition + 1 + currentIndex; popupsList[openerPosition] = listedTabs; currentIndexSet = true; break; case 'tabs': // the popup opener was found in one of the tabs in the window that will remain. setTabsInBrowser(firstWindow, listedTabs, openerPosition); // in this case current index is fixed because the to be focused tab // has now already been added to the remaining window currentIndex = openerPosition + 1 + currentIndex; break; case 'end': default: // no popup opener was found, the popup will be added at the end of the tab list. browsers = browsers.concat(listedTabs); currentIndex = firstWindowTabIndex + addedTabsLength + currentIndex; break; } } else { browsers = browsers.concat(listedTabs); currentIndex = firstWindowTabIndex + addedTabsLength + currentIndex; } } } else // the current window is a popup and should not be merged. currentIndex = firstWindowTabIndex + addedTabsLength + currentIndex; // add popup windows to the remaining window when popup windows should also be merged. if (mergePopups) { for (i = 0; i < popupsArray.length; i++) { tabs = popupsArray[i].getBrowser().mTabContainer.childNodes; if (placePopupNextToOpener) { listedTabs = listTabs(tabs, popupsArray[i]); var newWindowsArray = windowsArray; if (!currentWindowIsPopup && !mergeBackGround) newWindowsArray.push(currentWindow); openerPositionArray = getPopupOpenerPosition(popupsArray[i], newWindowsArray, firstWindowTabIndex); openerPosition = openerPositionArray[0]; switch (openerPositionArray[1]) { case 'browsers': // the popup opener was found in the list of browsers that will be added to the remaining window. if (openerPosition < currentIndex) currentIndex += tabs.length; if (popupsList[openerPosition] instanceof Array) popupsList[openerPosition] = popupsList[openerPosition].concat(listedTabs); else popupsList[openerPosition] = listedTabs; break; case 'tabs': // the popup opener was found in one of the tabs in the window that will remain. setTabsInBrowser(firstWindow, listedTabs, openerPosition); if (openerPosition < currentIndex) currentIndex += tabs.length; break; case 'end': default: // no popup opener was found, the pop up will be added at the end of the tab list. browsers = browsers.concat(listedTabs); break; } } else { browsers = browsers.concat(listTabs(tabs, popupsArray[i])); } } } // place all tabs in one window and select the tab which was selected in the top window setTabsInBrowser(firstWindow, browsers); // add popups which have openers next to their openers. while (popupsList.length > 0) { var popupTabs = popupsList.pop(); if (popupTabs instanceof Array) { var position = popupsList.length; setTabsInBrowser(firstWindow, popupTabs, position); } } // select the tab which was selected in the top window firstWindowTabBar.selectedIndex = currentIndex; // focus the window now containing the tabs and close all other windows firstWindow.focus(); // close windows from where tabs have been merged for (i = 1; i < windowsArray.length; i++) { windowsArray[i].close(); } // close popup windows if the popups have been merged if (mergePopups) { for (i = 0; i < popupsArray.length; i++) { popupsArray[i].close(); } } // if current window has been merged close it if (!dontMergeCurrentWindow) currentWindow.close(); // give focus again to the current window if it is a popup and popups should not be merged if (dontMergeCurrentWindow) setTimeout(windowsArrayList.currentWindow.focus, 0); } // retrieve the opener for a popup window, so it can be placed next to it function getPopupOpenerPosition(popupWindow, otherWindows, containerWindowTabsIndex) { var i, j, openerIndex = -1; var openerWindow = popupWindow.getBrowser().contentWindow.opener if (!openerWindow) { return [openerIndex, 'end']; } for (i = 0; i < otherWindows.length; i++) { if (otherWindows[i] == popupWindow) continue; var tabs = otherWindows[i].getBrowser().mTabContainer.childNodes; for (j = 0; j < tabs.length; j++) { openerIndex++; var possibleOpener = otherWindows[i].getBrowser().getBrowserForTab(tabs[j]).contentWindow; if (possibleOpener == openerWindow) { var where = (openerIndex >= containerWindowTabsIndex)? 'browsers': 'tabs'; return [openerIndex, where]; } } } return [-1, 'end']; } function listTabs(tabs, aWindow) { var x = 0, curBrowser, browsersArray = new Array(); for (x; x < tabs.length; x++) { curBrowser = aWindow.getBrowser().getBrowserForTab(tabs[x]); browsersArray[x] = [[dtMergeWindows.copyHistory(curBrowser.webNavigation.sessionHistory)], aWindow.SessionData.getTabProperties(tabs[x]), [curBrowser.contentWindow.scrollX, curBrowser.contentWindow.scrollY], curBrowser.markupDocumentViewer.textZoom]; } return browsersArray; } // add cloned tabs to a browser window function setTabsInBrowser(aWindow, pages) { var y = 0, openedBrowser, newTab; if (openTabNext) { var index = (aWindow == firstWindow)?firstWindowTabIndex:previousWindowTabIndex; } // add tabs to defined position in case of a popup: next to its opener var addToPosition = false; if (typeof(arguments[2]) == 'number') { addToPosition = true; var openerPosition = arguments[2]; var position = arguments[2]; } while (y < pages.length) { newTab = aWindow.getBrowser().addTab(); if (addToPosition && getBrowser().TMmoveTabTo) { var newTabPos = (aWindow.getBrowser().getTabIndex)? aWindow.getBrowser().getTabIndex(newTab): newTab._tPos; // the popup is placed next to its opener var newPosition = position + 1; if (newTabPos < newPosition) newPosition--; if (newTabPos != newPosition) aWindow.getBrowser().TMmoveTabTo((aWindow.getBrowser().getTabIndex)? newTabPos: newTab, newPosition); // set the opener again for the popup (this data will otherwise be lost) var openerBrowser = aWindow.getBrowser().getBrowserForTab(aWindow.getBrowser().mTabContainer.childNodes[openerPosition]); aWindow.getBrowser().getBrowserForTab(newTab).contentWindow.opener = openerBrowser.contentWindow; position++; } else if (openTabNext) { var firstArgument = (aWindow.getBrowser().getTabIndex)? aWindow.getBrowser().getTabIndex(newTab): newTab; aWindow.getBrowser().TMmoveTabTo(firstArgument, index + 1); index++; } openedBrowser = aWindow.getBrowser().getBrowserForTab(newTab); //we call setScrollPosition after load to make sure scrollPosition is set openedBrowser.addEventListener('load', aWindow.dupScrollPosition, true); openedBrowser._scrollData = { tabPos: newTab._tPos, href: null, _scrollX: pages[y][2][0], _scrollY: pages[y][2][1], zoom: pages[y][3] }; aWindow.SessionData.setTabProperties(newTab, pages[y][1]); dtMergeWindows.setClonedContent(openedBrowser, pages[y][0]); y++; } } }, // list all browser windows in een array from front to back (z-order on windows, on linux opening order); listWindows: function() { // function to check if a window is a popup or a normal window function isPopupWindow(domWin) { // the chrome flags are defined in the nsIWebBrowserChrome interface const webBrowserChrome = Components.interfaces.nsIWebBrowserChrome; var chromeBrowser = domWin.getBrowser().docShell.QueryInterface(Components.interfaces.nsIDocShellTreeItem) .treeOwner.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(webBrowserChrome); // check if all chrome is enabled in the window, using chromeFlags from nsIWebBrowserChrome var chromeAll = chromeBrowser.chromeFlags & webBrowserChrome.CHROME_ALL; if (chromeAll == webBrowserChrome.CHROME_ALL) { return false; // no popup window (the window has all chrome enabled) } // in other cases some chrome is missing from the window: popup window return true; } var windowsArray = new Array(), popupsArray = new Array(); var i = 0, winEnumerator, currentWindow, isCurrentWindowPopup, win; var windowsMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); currentWindow = windowsMediator.getMostRecentWindow('navigator:browser'); // on linux z enumerator does not work: use normal enumerator var platform = currentWindow.navigator.platform; if (platform.indexOf('Linux') != -1) { winEnumerator = windowsMediator.getEnumerator('navigator:browser'); while (winEnumerator.hasMoreElements()) { win = winEnumerator.getNext(); // list the currentWindow apart if (win == currentWindow.QueryInterface(Components.interfaces.nsIDOMWindow)) { currentWindow = win; isCurrentWindowPopup = isPopupWindow(win); continue; } if (isPopupWindow(win)) popupsArray.push(win); else windowsArray.push(win); } } else { // use getZOrderEnumerator on Windows and Mac; it does not work on linux winEnumerator = windowsMediator.getZOrderDOMWindowEnumerator('navigator:browser', false); while (winEnumerator.hasMoreElements()) { win = winEnumerator.getNext(); // list the current window apart if (win == currentWindow.QueryInterface(Components.interfaces.nsIDOMWindow)) { currentWindow = win; isCurrentWindowPopup = isPopupWindow(win); continue; } if (isPopupWindow(win)) popupsArray.push(win); else { windowsArray.push(win); } } } var windowsList = {windowsArray: windowsArray, popupsArray: popupsArray, currentWindow: currentWindow, isCurrentWindowPopup: isCurrentWindowPopup}; return windowsList; }, setClonedContent: function(aBrowser, aClonedContents) { if (aClonedContents[0].length == 0) return; this.clonedContents = aClonedContents; this.newBrowser = aBrowser; this.cloneTabHistory(aBrowser.webNavigation, aClonedContents[0]); }, cloneHistoryEntry: function(aEntry) { if (!aEntry) return null; aEntry = aEntry.QueryInterface(Components.interfaces.nsISHContainer); var newEntry = aEntry.clone(); newEntry = newEntry.QueryInterface(Components.interfaces.nsISHContainer); newEntry.loadType = Math.floor(aEntry.loadType); if (aEntry.childCount) { for (var j = 0; j < aEntry.childCount; j++) { var childEntry = dtMergeWindows.cloneHistoryEntry(aEntry.GetChildAt(j)); if (childEntry) newEntry.AddChild(childEntry, j); } } return newEntry; }, cloneTabHistory: function(webNav, originalHistory) { var newHistory = webNav.sessionHistory newHistory.QueryInterface(Components.interfaces.nsISHistoryInternal); // delete history entries if they are present if (newHistory.count > 0) newHistory.PurgeHistory(newHistory.count); for (var i = 0; i < originalHistory.length; i++) { var entry = originalHistory[i].QueryInterface(Components.interfaces.nsISHEntry); var newEntry = dtMergeWindows.cloneHistoryEntry(entry); newHistory.addEntry(newEntry, true); } // Goto current history location if (originalHistory.length > 0 && originalHistory.index < originalHistory.length) { try { webNav.gotoIndex(originalHistory.index); } catch(e) { window.setTimeout( function (webNav, index) { webNav.gotoIndex(index); }, 0, webNav, originalHistory.index); } } }, copyHistory: function(originalHistory, aOnlyBack) { // variables used in this function var pageCount, currentPageNum, firstPageNum, lastPageNum; currentPageNum = originalHistory.index; lastPageNum = originalHistory.count-1; firstPageNum = 0; pageCount = lastPageNum+1; currentPageNum = currentPageNum-firstPageNum; var copiedHistory = new Array(); for (var i = firstPageNum; i < pageCount; i++) { copiedHistory.push(originalHistory.getEntryAtIndex(i, false)); } copiedHistory.index = currentPageNum; return copiedHistory; } }; PK 844"content/tabmixplus/flst/lasttab.js/*//////////////////////////////////////////////////////////////////// // The Original Code is the "LastTab" extension for Mozilla Firefox.// // version 1.5 - October 26, 2005 // // The Initial Developer of the Original Code is Timothy Humphrey. // *//////////////////////////////////////////////////////////////////// var TMP_LastTab = { CtrlKey : false, favorLeftToRightOrdering : true, handleCtrlTab : true, KeyboardNavigating : true, KeyLock : false, respondToMouseInTabList : true, showTabList : true, SuppressTabListReset : false, TabHistory : [], TabIndex : 0, TabList : null, TabListLock : false, _inited: false, DisplayTabList : function() { var element = document.documentElement; var tablist = this.TabList; var menuitem, tab, imageUrl, x, y, i, activeIndex; createCommonList(tablist, this.handleCtrlTab ? 3 : 2); var item = tablist.childNodes[this.TabIndexToMenuItem()]; item.setAttribute("_moz-menuactive", "true"); updateMenuItemActive(null, item); //moveTo() method introduces anomalies, e.g. hovering over location bar moves the popup; hiding and showing the popup works better document.popupNode = element; x = -element.boxObject.screenX; y = 10000; tablist.showPopup(element, x, y, "popup", null, null); //show offscreen to get popup measurements x = Math.round((window.outerWidth - tablist.boxObject.width) / 2) - (element.boxObject.screenX - window.screenX); y = Math.round((window.outerHeight - tablist.boxObject.height) / 2) - (element.boxObject.screenY - window.screenY); if(x + element.boxObject.screenX < 0) x = -element.boxObject.screenX; else if(x + element.boxObject.screenX + tablist.boxObject.width > window.screen.availWidth) x = window.screen.availWidth - tablist.boxObject.width - element.boxObject.screenX; if(y + element.boxObject.screenY < 0) y = -element.boxObject.screenY; else if(y + element.boxObject.screenY + tablist.boxObject.height > window.screen.availHeight) y = window.screen.availHeight - tablist.boxObject.height - element.boxObject.screenY; if(x == -1 && y == -1) //workaround special status of -1, -1 position in showPopup() method x = y = 0; this.SuppressTabListReset = true; tablist.hidePopup(); this.SuppressTabListReset = false; tablist.showPopup(element, x, y, "popup", null, null); var ietab = "chrome://ietab/content/reloaded.html?url=" if (gBrowser.currentURI.spec.indexOf(ietab) == 0) tablist.focus(); this.TabListLock = true; }, init : function() { this._inited = true; var browser = document.documentElement; this.TabList = document.getElementById("lasttabTabList"); if ("_keyEventHandler" in gBrowser.mTabBox) gBrowser.mTabBox._eventNode.removeEventListener("keypress", gBrowser.mTabBox._keyEventHandler, false); else // we are after Bug 156459 fixed (2007-11-15) gBrowser.mTabBox._eventNode.removeEventListener("keypress", gBrowser.mTabBox, false); browser.addEventListener("keydown", this, true); browser.addEventListener("keypress", this, true); browser.addEventListener("keyup", this, true); this.TabList.addEventListener("DOMMenuItemActive", this, true); this.TabList.addEventListener("DOMMenuItemInactive", this, true); gBrowser.selectedTab.__LastTab = true; this.TabHistory.push(gBrowser.selectedTab); if (gBrowser.selectedTab._tPos != 0) { // if session manager select other tab then the first one we need to build TabHistory in two steps // to maintain natural Ctrl-Tab order. // we call MaintainTabHistory from here the 2nd time is call from OnSelect. this.MaintainTabHistory(gBrowser.selectedTab._tPos); } // we change pref string in tabmixplus 0.3 if (tabxPrefs.prefHasUserValue("HandleCtrlTab")) { tabxPrefs.setBoolPref("lasttab.handleCtrlTab", tabxPrefs.getBoolPref("HandleCtrlTab")); tabxPrefs.clearUserPref("HandleCtrlTab"); } if (tabxPrefs.prefHasUserValue("CtrlTabLeftToRight")) { tabxPrefs.clearUserPref("CtrlTabLeftToRight"); } this.ReadPreferences(); }, deinit : function() { var browser = document.documentElement; browser.removeEventListener("keydown", this, true); browser.removeEventListener("keypress", this, true); browser.removeEventListener("keyup", this, true); this.TabList.removeEventListener("DOMMenuItemActive", this, true); this.TabList.removeEventListener("DOMMenuItemInactive", this, true); }, handleEvent : function(event) { switch (event.type) { case "keydown": this.OnKeyDown(event); break; case "keypress": this.OnKeyPress(event); break; case "keyup": this.OnKeyUp(event); break; case "DOMMenuItemActive": this.ItemActive(event); break; case "DOMMenuItemInactive": this.ItemInactive(event); break; } }, ItemActive : function(event) { updateMenuItemActive(event); if(this.respondToMouseInTabList) { if(this.KeyboardNavigating) { if(event.target.value != this.inverseIndex(this.TabIndex)) this.TabList.childNodes[this.TabIndexToMenuItem()].setAttribute("_moz-menuactive", "false"); this.KeyboardNavigating = false; } this.TabIndex = this.inverseIndex(event.target.value); } else { if(event.target.value != this.inverseIndex(this.TabIndex)) event.target.setAttribute("_moz-menuactive", "false"); } }, ItemInactive : function(event) { updateMenuItemInactive(event); if(!this.respondToMouseInTabList && event.target.value == this.inverseIndex(this.TabIndex)) event.target.setAttribute("_moz-menuactive", "true"); }, MaintainTabHistory : function(lastIndex) { var newTabs = [], tab, i; // Gather tab synchronization info if (typeof(lastIndex)=="undefined") lastIndex = gBrowser.mTabContainer.childNodes.length; for(i = 0; i < lastIndex; i++) { tab = gBrowser.mTabContainer.childNodes[i]; if(!tab.__LastTab) newTabs[newTabs.length] = tab; } // Purge old tab info from history i = 0; try{ while(i < this.TabHistory.length) { if(!this.TabHistory[i] || this.TabHistory[i].parentNode != gBrowser.mTabContainer) this.TabHistory.splice(i, 1); else i++; } } catch (e) {tmLog("error from Ctrl+Tab in MaintainTabHistory " + typeof(this.TabHistory[i]) + "\n" + e + "\n" + "this.TabHistory.length " + this.TabHistory.length + "\n" + "i " + i);} // Add new tabs to history if(newTabs.length > 0) { tab = this.TabHistory.pop(); if(this.favorLeftToRightOrdering) { for(i = newTabs.length - 1; i >= 0; i--) { newTabs[i].__LastTab = true; this.TabHistory.push(newTabs[i]); } } else { for(i = 0; i < newTabs.length; i++) { newTabs[i].__LastTab = true; this.TabHistory.push(newTabs[i]); } } this.TabHistory.push(tab); } }, OnKeyDown : function(event) { this.CtrlKey = event.ctrlKey && !event.altKey && !event.metaKey; }, OnKeyPress : function _LastTab_OnKeyPress(event) { var tabCount = this.handleCtrlTab ? this.TabHistory.length : gBrowser.mTabs.length; if((this.handleCtrlTab || this.showTabList) && event.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_TAB && event.ctrlKey && !event.altKey && !event.metaKey) { if(!this.KeyLock) { if (this.handleCtrlTab) { this.MaintainTabHistory(); tabCount = this.TabHistory.length; this.TabIndex = tabCount - 1; } else { this.TabIndex = tabCount - 1 - gBrowser.mCurrentTab._tPos; } this.KeyLock = true; } if(this.TabListLock) this.TabList.childNodes[this.TabIndexToMenuItem()].setAttribute("_moz-menuactive", "false"); if(event.shiftKey) { this.TabIndex++; if(this.TabIndex >= tabCount) this.TabIndex = 0; } else { this.TabIndex--; if(this.TabIndex < 0) this.TabIndex = tabCount - 1; } if(this.showTabList) { this.KeyboardNavigating = true; if(!this.TabListLock) { if(tabCount > 1) this.DisplayTabList(); } else { var item = this.TabList.childNodes[this.TabIndexToMenuItem()]; item.setAttribute("_moz-menuactive", "true"); updateMenuItemActive(null, item); } } else { TMP_tabSelectedFromList(this.TabHistory[this.TabIndex]); } event.stopPropagation(); event.preventDefault(); } else { if(this.TabListLock) this.TabList.hidePopup(); if ("_keyEventHandler" in gBrowser.mTabBox) gBrowser.mTabBox._keyEventHandler.handleEvent(event); else // we are after Bug 156459 fixed (2007-11-15) gBrowser.mTabBox.handleEvent(event); } }, OnKeyUp : function _LastTab_OnKeyUp(event) { var keyReleased = event.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_CONTROL; this.CtrlKey = event.ctrlKey && !event.altKey && !event.metaKey; if(keyReleased && this.TabListLock) { if(this.TabList.childNodes[this.TabIndexToMenuItem()].getAttribute("_moz-menuactive") == "true") { var tabToSelect = this.handleCtrlTab ? this.TabHistory[this.TabIndex] : gBrowser.mTabs[gBrowser.mTabs.length - 1 - this.TabIndex]; TMP_tabSelectedFromList(tabToSelect); } updateMenuItemInactive(null); gBackupLabel==""; this.PushSelectedTab(); this.TabList.hidePopup(); } if(keyReleased && this.KeyLock) { this.PushSelectedTab(); this.TabIndex = 0; this.KeyLock = false; } }, OnMenuCommand : function _LastTab_OnMenuCommand(event) { if(this.respondToMouseInTabList) { var tabToSelect = this.handleCtrlTab ? this.TabHistory[event.target.value] : gBrowser.mTabs[event.target.value]; TMP_tabSelectedFromList(tabToSelect); this.PushSelectedTab(); } }, OnPopupHidden : function() { if(!this.SuppressTabListReset) { var tablist = this.TabList; while(tablist.childNodes.length > 0) tablist.removeChild(tablist.childNodes[0]); this.TabListLock = false; this.TabIndex = 0; this.KeyLock = false; hideCommonList(tablist); } }, OnSelect : function() { // session manager can select new tab befor TMP_LastTab is init if (!this._inited) return; var tabCount = this.TabHistory.length; this.MaintainTabHistory(); if(tabCount != gBrowser.mTabContainer.childNodes.length) { if(tabCount > gBrowser.mTabContainer.childNodes.length) { if(gBrowser.mTabContainer.childNodes.length == 1) { this.KeyLock = false; this.TabIndex = 0; } } this.PushSelectedTab(); } else if(!this.KeyLock) { if(this.CtrlKey) this.KeyLock = true; //allow other tab navigation methods to work else this.PushSelectedTab(); } }, PushSelectedTab : function() { var selectedTab = gBrowser.mTabContainer.selectedItem; var tabCount, i; if(this.TabHistory[this.TabHistory.length - 1] != selectedTab) { tabCount = this.TabHistory.length; for(i = 0; i < tabCount; i++) { if(this.TabHistory[i] == selectedTab) { this.TabHistory.push(this.TabHistory.splice(i, 1)[0]); break; } } } }, ReadPreferences : function() { this.handleCtrlTab = tabxPrefs.getBoolPref("lasttab.handleCtrlTab"); this.favorLeftToRightOrdering = tabxPrefs.getBoolPref("lasttab.favorLeftToRightOrdering"); this.respondToMouseInTabList = tabxPrefs.getBoolPref("lasttab.respondToMouseInTabList"); this.showTabList = tabxPrefs.getBoolPref("lasttab.showTabList"); }, TabIndexToMenuItem : function() { var activeIndex; if (this.handleCtrlTab) activeIndex = this.TabHistory.length - 1 - this.TabIndex; else activeIndex = gBrowser.mTabs.length - 1 - this.TabIndex; return activeIndex; }, inverseIndex : function(index) { return this.handleCtrlTab ? index : gBrowser.mTabs.length - 1 - index; } } PK 8content/tabmixplus/history/PK U6z%dd,content/tabmixplus/history/history-panel.xul PK 2{p8_J%content/tabmixplus/history/history.jsvar Click2TabHistoryPanel = { init : function () { window.removeEventListener('load', function () { Click2TabHistoryPanel.init(); }, false); if (typeof(PlacesController) == "function") { TMP_Places.init(); return; } TMP_update_whereToOpen(); eval("openURL = " + openURL.toString().replace( 'openURLIn(whereToOpenLink(aEvent));', 'openURLIn(whereToOpenLinkTabmix(aEvent, prefStringTMHistory));' )); eval("buildContextMenu ="+buildContextMenu.toString() .replace('openItemInNewTab.hidden = false;', '$& TMP_updateContextMenu(openItem, openItemInNewWindow, openItemInNewTab, prefStringTMHistory);' )); } } PK 8content/tabmixplus/links/PK 8IkIk(content/tabmixplus/links/contentLinks.js/* * chrome://tabmixplus/content/links/contentLinks.js * * original code by Bradley Chapman * modified and developped by Hemiola SUN * modified again by Bradley Chapman * */ var gIOService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); var gPref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); var gWindowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); /** * @brief Open the given link node in the current window. * * @param event A valid event union. * @param linkNode The DOM node containing the URL to open. * @param currentTab A Boolean value. If true, the URL will be opened * within the current tab. If false, it will be * opened in a new tab. * @returns True if the function opened a URL, or the value * of handleLinkClick() if it chose not to. * */ function TMP_howToOpen(event, linkNode, currentTab) { // this helper function parses the event union for us // and makes a better determination of how a link will // be opened var where = whereToOpenLink(event); if (where == "save" || where == "window" ) { handleLinkClick(event, linkNode.href, linkNode); return true; } if ("webPanelSecurityCheck" in window) { // webPanelSecurityCheck was removed at 18/02/2007 if (!webPanelSecurityCheck(linkNode.ownerDocument.location.href, linkNode.href)) return false; } else { // for Firefox 3.0 after bug 370765 landed try { urlSecurityCheck(linkNode.href, linkNode.ownerDocument.nodePrincipal); } catch(ex) { return false; } } var postData = { }; var url = getShortcutOrURI(linkNode.href, postData); if (!url) return true; // if where is "tab", "tabshifted", "current" callers will control the inversion of currentTab var docURL = event.target.ownerDocument.location.href; // referrer header if (currentTab) { var referrerURI = gIOService.newURI(docURL, null, null); window.loadURI(url, referrerURI, postData.value, false); event.preventDefault(); return false; } else { try{ var f = window.openNewTabWith.toString(); if (f.indexOf("aEvent") > -1 ) window.openNewTabWith(url, event.target.ownerDocument, null, event, false); // firefox 3.0 + else if (f.indexOf("event") > f.indexOf("postData")) window.openNewTabWith(url, docURL, null, event, false); // firefox 1.5 + else window.openNewTabWith(url, linkNode, event, true, null); // firefox 1.0.x } catch (e) {} event.preventDefault(); return true; } } /** * @brief Check for certain JavaScript strings inside an attribute. * * @param attr The attribute to check. * @param string The string to check for. * @returns true if the strings are present, false if they aren't. * */ function TMP_checkAttr(attr, string) { if (typeof(attr) == "string") return attr.indexOf(string) == 0; return false; } /** * @brief Check if link refers to external domain. * * @param target The target link. * @param curpage The current page url * @returns current domain and target domain * */ function checkDomain(curpage, target) { function getDomain(url) { if (typeof(url) != "string") url = url.toString(); if (url.match(/^file:/)) return "local_file"; if (url.match(/^http/)) { url = gIOService.newURI(url, null, null); // catch redirect if (url.path.match(/^\/r\/\?http/)) url = gIOService.newURI(url.path.substr("/r/?".length), null, null); var host = url.hostPort.split("."); while (host.length > 2) host.shift(); return host.join("."); } return null; } return {current: getDomain(curpage), target: getDomain(target)}; } /** * @brief Handle left-clicks inside a browser viewport. * * This function is the primary entry point for all left-clicks on a browser * page; we triage and sort such clicks and handle the ones we want and pass * on the ones that we don't. * * @param event A valid event union. * @param fieldNormalClicks A Boolean value. If true, we will handle all left-clicks * that invoke this function. If false, we will only handle * the ones that require additional legwork (i.e. locked tabs). * @returns Either the return value of __contentAreaClick(), or the * return value of handleLinkClick(), or true if the function * was passed an event it could not handle. */ function TMP_contentAreaClick(event, fieldNormalClicks) { try { var targetPref = gPref.getIntPref("extensions.tabmix.speLink"); var linkTarget = gPref.getBoolPref("extensions.tabmix.linkTarget"); var suppressTabs = gPref.getBoolPref("extensions.tabmix.enablefiletype") } catch(e) {} // use the default if either of these are activated if (!event.isTrusted || event.getPreventDefault()) { return true; } var target = event.target; var linkNode; var where = whereToOpenLink(event); if (target instanceof HTMLButtonElement || target instanceof HTMLInputElement) { if (typeof(SubmitToTab)!='undefined' && SubmitToTab.contentAreaClick(event) == false) { return false; } } if (target instanceof HTMLAnchorElement || target instanceof HTMLAreaElement || target instanceof HTMLLinkElement) { if (target.hasAttribute("href")) linkNode = target; // xxxmpc: this is kind of a hack to work around a Gecko bug (see bug 266932) // we're going to walk up the DOM looking for a parent link node, // this shouldn't be necessary, but we're matching the existing behaviour for left click var parent = target.parentNode; while (parent) { if (parent instanceof HTMLAnchorElement || parent instanceof HTMLAreaElement || parent instanceof HTMLLinkElement) { if (parent.hasAttribute("href")) linkNode = parent; } parent = parent.parentNode; } } else { linkNode = event.originalTarget; while (linkNode && !(linkNode instanceof HTMLAnchorElement)) linkNode = linkNode.parentNode; // cannot be nested. So if we find an anchor without an // href, there is no useful around the target if (linkNode && !linkNode.hasAttribute("href")) linkNode = null; else if (linkNode && linkNode.hasAttribute("href")) target = linkNode; } if (!linkNode) return __contentAreaClick(event, fieldNormalClicks); // Check if new tab already opened from onclick event // 2006-09-26 if (target.hasAttribute("onclick") && gBrowser.contentDocument.location.href != document.commandDispatcher.focusedWindow.top.location.href) return true; // Check if link refers to external domain. // Get current page url var curpage = linkNode.ownerDocument.location.href; // 2006-09-29 var domain = checkDomain(curpage, target); var targetDomain = domain.target; var currentDomain = domain.current; var openT = linkNode.getAttribute("target"); // If link has no target attribute, check if there is a with a target attribute if (!openT) { var b = document.commandDispatcher.focusedWindow.document.getElementsByTagName("base"); if (b.length > 0) openT = b[0].getAttribute("target"); } if (linkNode.getAttribute("rel") == "sidebar" || openT == "_search" || linkNode.getAttribute("href").indexOf("mailto:") > -1) { return __contentAreaClick(event, fieldNormalClicks); } /* * prevent tabs from opening if left-clicked link ends with given filetype or matches regexp; * portions were taken from disable target for downloads by cusser * */ if (TMP_suppressTabsOnFileDownload(event, target, linkNode, suppressTabs)) { // don't do anything if we are on gmail and let gmail to take care of the download var isGmail = /^http:\/\/mail.google.com\/mail/.test(target.ownerDocument.location.href); if (isGmail) return true; else return TMP_howToOpen(event, linkNode, true); } /* * force a middle-clicked link to open in the current tab if certain conditions * are true. See the function comment for more details. * */ if (TMP_divertMiddleClick(event, linkNode, gBrowser.mCurrentTab, currentDomain, targetDomain, targetPref, gPref.getBoolPref("extensions.tabmix.middlecurrent"))) { return TMP_howToOpen(event, linkNode, true); } // catch other middle & right click if (event.button != 0) { handleLinkClick(event, linkNode.href, linkNode); return true; } // the rest of the code if for left-click only /* * open targeted links in the current tab only if certain conditions are met. * See the function comment for more details. * */ if (TMP_divertTargetedLink(event, target, linkNode, openT, document.commandDispatcher.focusedWindow.top.frames, gBrowser.mCurrentTab, currentDomain, targetDomain, targetPref, linkTarget)) { return TMP_howToOpen(event, linkNode, true); } /* * open links to other sites in a tab only if certain conditions are met. See the * function comment for more details. * */ if (TMP_openExSiteLink(event, target, linkNode, currentDomain, targetDomain, targetPref)) { return TMP_howToOpen(event, linkNode, false); } if (gBrowser.mCurrentTab.hasAttribute("locked")) { // tab is locked var href = null, onclick = null; if (target.hasAttribute("href")) href = target.getAttribute("href").toLowerCase(); if (target.hasAttribute("onclick")) onclick = target.getAttribute("onclick"); if (TMP_checkAttr(href, "javascript:") || TMP_checkAttr(href, "data:") || TMP_checkAttr(onclick, "window.open") || TMP_checkAttr(onclick, "NewWindow") || TMP_checkAttr(onclick, "PopUpWin") || (onclick && onclick.indexOf('this.target="_Blank"') != -1) || TMP_checkAttr(onclick, "return ")) { ; // javascript links, do nothing! } else { var current = TMP_checkAttr(href, "#"); return TMP_howToOpen(event, linkNode, current); } } // use whereToOpenLink() to determine if no modifiers were used else if (where == "current") { if (fieldNormalClicks && (!openT || openT == "_content" || openT == "_main")) return __contentAreaClick(event, fieldNormalClicks); else if (linkNode.hasAttribute("onclick")) return __contentAreaClick(event, fieldNormalClicks); else if (openT) handleLinkClick(event, linkNode.href, linkNode); } else handleLinkClick(event, linkNode.href, linkNode); return true; } /** * @brief Suppress tabs that may be created by downloading a file. * * This code borrows from Cusser's Disable Targets for Downloads extension. * * @param event A valid event union. * @param target The target of the event. * @param linkNode The DOM node containing the URL to be opened. * @param suppressTabs A Boolean value that controls controlling how the link should be opened. * @returns true if the link was handled by this function. * */ function TMP_suppressTabsOnFileDownload(event, target, linkNode, suppressTabs) { // prevent link with "custombutton" protocol to open new tab when custombutton extension exist if (event.button != 2 && typeof(custombuttons) !='undefined'){ if (TMP_checkAttr(linkNode.toString(), "custombutton://")) return true; } if (event.button != 0 || event.ctrlKey || event.metaKey || !suppressTabs) return false; // lets try not to look into links that start with javascript (from 2006-09-02) if (TMP_checkAttr(linkNode.toString(), "javascript:")) return false; if (target.hasAttribute("onclick")) { var onclick = target.getAttribute("onclick"); if (TMP_checkAttr(onclick, "return install") || TMP_checkAttr(onclick, "return installTheme") || TMP_checkAttr(onclick, "return note") || TMP_checkAttr(onclick, "return log")) // click on link in http://tinderbox.mozilla.org/showbuilds.cgi return true; } // prevent links in tinderbox.mozilla.org with linkHref to *.gz from open in this function if (TMP_checkAttr(linkNode.toString() , "http://tinderbox.mozilla.org/showlog") || TMP_checkAttr(linkNode.toString() , "http://tinderbox.mozilla.org/addnote")) return false; return isUrlForDownload(target.getAttribute("href")) } function isUrlForDownload(linkHref) { var filetype = gPref.getCharPref("extensions.tabmix.filetype"); filetype = filetype.toLowerCase(); filetype = filetype.split(" "); var linkHrefExt = ""; if (linkHref) { linkHref = linkHref.toLowerCase(); linkHrefExt = linkHref.substring(linkHref.lastIndexOf("/"),linkHref.length); linkHrefExt = linkHrefExt.substring(linkHrefExt.indexOf("."),linkHrefExt.length); } var testString, hrefExt, testExt; for (var l = 0; l < filetype.length; l++) { if (filetype[l].indexOf("/") != -1){ // add \ befor first ? testString = filetype[l].substring(1,filetype[l].length-1).replace(/^\?/,"\\?"); hrefExt = linkHref; } else { testString = "\\." + filetype[l]; hrefExt = linkHrefExt; try { // prevent filetype catch if it is in the middle of a word testExt = new RegExp(testString + "[a-z0-9?\.]+", 'i'); if (testExt.test(hrefExt)) continue; } catch (ex) {} } try { testExt = new RegExp(testString, 'i'); if (testExt.test(hrefExt)) return true; } catch (ex) {} } return false; } /** * @brief Divert middle-clicked links into the current tab. * * This function forces a middle-clicked link to open in the current tab if * the following conditions are true: * * - links to other sites are not configured to open in new tabs AND the current * page domain and the target page domain do not match OR the current * tab is locked * - middle-clicks are configured to open in the current tab AND the middle * mouse button was pressed OR the left mouse button and one of the Ctrl/Meta keys * was pressed * * @param event A valid event union. * @param linkNode The DOM node containing the URL to open. * @param currentTab A scripted tab object from the tabbrowser. * @param currentDomain The domain name of the website URL in the current tab. * @param targetDomain The domain name of the website URL in the link node. * @param targetPref An integer value that specifies whether or not links should * be forced into new tabs. * @param middlePref A Boolean value that controls how middle clicks are handled. * @returns true if the function handled the click, false if it didn't. * */ function TMP_divertMiddleClick(event, linkNode, currentTab, currentDomain, targetDomain, targetPref, middlePref) { if (!middlePref) return false; var isTabLocked = currentTab.hasAttribute("locked"); var isDifDomain = targetPref == 2 && targetDomain && targetDomain != currentDomain; if (!isTabLocked && !isDifDomain) return false; if (event.button == 1 || event.button == 0 && (event.ctrlKey || event.metaKey)) return true; return false; } /** * @brief Divert links that contain targets to the current tab. * * This function forces a link with a target attribute to open in the * current tab if the following conditions are true: * * - linkTarget is set * - neither of the Ctrl/Meta keys were used AND the linkNode has a target attribute * AND the content of the target attribute is not one of the special frame targets * AND it is not present in the document frame pool * - links to other sites are not configured to open in new tabs AND the domain name * of the current page and the domain name of the target page do not match * - the current tab is not locked * - the domain name of the current page and the domain name of the target page * do not match * - the target of the event has an onclick attribute that does not contain the * function call 'window.open' or the function call 'return top.js.OpenExtLink' * * @param event A valid event union. * @param target The target of the event. * @param linkNode The DOM node containing the URL to be opened. * @param targetAttr The target attribute of the link node. * @param frames The frame pool of the current document. * @param currentTab A scripted tab object from the tabbrowser. * @param currentDomain The domain name of the website URL loaded in the current tab. * @param targetDomain The domain name of the website URL to be loaded. * @param targetPref An integer value that specifies whether or not links should * be forced into new tabs. * @param linkTarget An integer value that specifies how normal links * that spawn new windows are handled. * @returns true if the function handled the click, false if it didn't. * */ function TMP_divertTargetedLink(event, target, linkNode, targetAttr, frames, currentTab, currentDomain, targetDomain, targetPref, linkTarget) { if (!linkTarget) return false; if (TMP_checkAttr(linkNode.toString(), "javascript:") || // 2005-11-28 some link in Bloglines start with javascript TMP_checkAttr(linkNode.toString(), "data:")) return false; if (event.ctrlKey || event.metaKey) return false; if (!targetAttr) return false; var targetString = /^(_self|_parent|_top|_content|_main)$/; if (targetString.test(targetAttr.toLowerCase())) return false; if (TMP_existsFrameName(frames, targetAttr)) return false; if (targetPref == 2 && targetDomain && targetDomain != currentDomain) return false; if (currentTab.hasAttribute("locked")) return false; if (targetDomain && targetDomain == currentDomain) return false; if (target.hasAttribute("onclick")) { var onclick = target.getAttribute("onclick"); if (TMP_checkAttr(onclick, "window.open") || TMP_checkAttr(onclick, "NewWindow") || TMP_checkAttr(onclick, "PopUpWin") || TMP_checkAttr(onclick, "return ")) return false; } return true; } /** * @brief Open links to other sites in tabs as directed. * * This function opens links to external sites in tabs as long as the following * conditions are met: * * - links to other sites are configured to open in tabs * - the link node does not have an 'onclick' attribute that contains either the function call * 'window.open' or the function call 'return top.js.OpenExtLink'. * - the domain name of the current page and the domain name of the target page do not match * OR the link node has an 'onmousedown' attribute that contains the text 'return rwt' * * @param event A valid event union. * @param target The target of the event. * @param linkNode The DOM node containing the URL to be opened. * @param currentDomain The domain name of the website URL loaded in the current tab. * @param targetDomain The domain name of the website URL to be loaded. * @param targetPref An integer value that specifies whether or not links should * be forced into new tabs. * @returns true if the function handled the click, false if it