From 66abbbf8519a65ee0d8188b72d18122ab5146321 Mon Sep 17 00:00:00 2001 From: mastef Date: Sun, 22 Sep 2024 22:05:46 +0700 Subject: [PATCH] firefox 5.2.1 built version --- outlib/Tab.js | 12 +++++++----- outlib/TabManager.js | 13 ++++++++----- outlib/TabOptions.js | 2 +- outlib/TabOptionsFirefox.js | 2 +- outlib/Window.js | 34 +++++++++++++++++++++++++++------- 5 files changed, 44 insertions(+), 19 deletions(-) diff --git a/outlib/Tab.js b/outlib/Tab.js index 1c4e4096..e1e063f3 100644 --- a/outlib/Tab.js +++ b/outlib/Tab.js @@ -49,7 +49,7 @@ Tab = function (_React$Component) {_inherits(Tab, _React$Component); children.push( React.createElement("div", { key: "tab-title-" + this.props.tab.id, className: "tabtitle" }, - this.props.tab.title)); + this.props.tab.title || "")); } @@ -139,7 +139,7 @@ Tab = function (_React$Component) {_inherits(Tab, _React$Component); e) { if (!!this.props.drag) { e.dataTransfer.setData("Text", this.props.tab.id); - e.dataTransfer.setData("text/uri-list", this.props.tab.url); + e.dataTransfer.setData("text/uri-list", this.props.tab.url || ""); this.props.drag(e, this.props.tab.id); } else { return false; @@ -170,7 +170,7 @@ Tab = function (_React$Component) {_inherits(Tab, _React$Component); } else { return false; } - } }, { key: "resolveFavIconUrl", value: function () {var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {var image, favIcons, iconName;return regeneratorRuntime.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0: + } }, { key: "resolveFavIconUrl", value: function () {var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {var image, favIcons, iconUrl, iconName;return regeneratorRuntime.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0: // firefox screenshots; needs @@ -179,7 +179,7 @@ Tab = function (_React$Component) {_inherits(Tab, _React$Component); // image = await browser.tabs.captureTab(this.props.tab.id); // image = "url(" + image + ")"; // }else - if (this.props.tab.url.indexOf("chrome://") !== 0 && this.props.tab.url.indexOf("about:") !== 0) { + if (!!this.props.tab.url && this.props.tab.url.indexOf("chrome://") !== 0 && this.props.tab.url.indexOf("about:") !== 0) { // chrome screenshots / only for active tabs; needs // if(!!browser.tabs.captureVisibleTab && this.props.tab.highlighted) { // console.log("tabsCapture"); @@ -195,7 +195,9 @@ Tab = function (_React$Component) {_inherits(Tab, _React$Component); //} } else { favIcons = ["bookmarks", "chrome", "crashes", "downloads", "extensions", "flags", "history", "settings"]; - iconName = this.props.tab.url.slice(9).match(/^\w+/g); + iconUrl = this.props.tab.url || ""; + iconName = ""; + if (iconUrl.length > 9) iconName = iconUrl.slice(9).match(/^\w+/g); image = !iconName || favIcons.indexOf(iconName[0]) < 0 ? "" : "url(../images/chrome/" + iconName[0] + ".png)"; } this.setState({ diff --git a/outlib/TabManager.js b/outlib/TabManager.js index 96a1cd76..d2fa5676 100644 --- a/outlib/TabManager.js +++ b/outlib/TabManager.js @@ -52,7 +52,7 @@ TabManager = function (_React$Component) {_inherits(TabManager, _React$Component if (typeof localStorage["sessionsFeature"] === "undefined") localStorage["sessionsFeature"] = "0"; if (typeof localStorage["hideWindows"] === "undefined") localStorage["hideWindows"] = "0"; if (typeof localStorage["filter-tabs"] === "undefined") localStorage["filter-tabs"] = "0"; - if (typeof localStorage["version"] === "undefined") localStorage["version"] = "5.2.0"; + if (typeof localStorage["version"] === "undefined") localStorage["version"] = "5.2.1"; layout = localStorage["layout"]; tabLimit = JSON.parse(localStorage["tabLimit"]); @@ -170,8 +170,8 @@ TabManager = function (_React$Component) {_inherits(TabManager, _React$Component this.update(); } }, { key: "hoverHandler", value: function hoverHandler( tab) { - this.setState({ topText: tab.title }); - this.setState({ bottomText: tab.url }); + this.setState({ topText: tab.title || "" }); + this.setState({ bottomText: tab.url || "" }); // clearTimeout(this.state.closeTimeout); // this.state.closeTimeout = setTimeout(function () { // window.close(); @@ -188,7 +188,7 @@ TabManager = function (_React$Component) {_inherits(TabManager, _React$Component } }, { key: "hoverIcon", value: function hoverIcon( e) { var text = ""; - if (e && e.target && e.target.title) { + if (e && e.target && !!e.target.title) { text = e.target.title; } var bottom = " "; @@ -809,7 +809,10 @@ TabManager = function (_React$Component) {_inherits(TabManager, _React$Component } for (var id in idList) { var tab = this.state.tabsbyid[id]; - var tabSearchTerm = (tab.title + tab.url).toLowerCase(); + var tabSearchTerm; + if (!!tab.title) tabSearchTerm = tab.title; + if (!!tab.url) tabSearchTerm += " " + tab.url; + tabSearchTerm = tabSearchTerm.toLowerCase(); var match = false; if (searchType == "normal") { match = tabSearchTerm.indexOf(e.target.value.toLowerCase()) >= 0; diff --git a/outlib/TabOptions.js b/outlib/TabOptions.js index f70b5a26..0d7adedf 100644 --- a/outlib/TabOptions.js +++ b/outlib/TabOptions.js @@ -6,7 +6,7 @@ TabOptions = function (_React$Component) {_inherits(TabOptions, _React$Component _this.state = {};return _this; }_createClass(TabOptions, [{ key: "logo", value: function logo() { - var logo = [React.createElement("img", { src: "images/browsers.svg", style: { maxWidth: "3rem" } }), React.createElement("h2", null, "Tab Manager Plus ", "5.2.0")]; + var logo = [React.createElement("img", { src: "images/browsers.svg", style: { maxWidth: "3rem" } }), React.createElement("h2", null, "Tab Manager Plus ", "5.2.1")]; return ( React.createElement("div", { className: "logo-options" }, diff --git a/outlib/TabOptionsFirefox.js b/outlib/TabOptionsFirefox.js index 04570fff..1d995cba 100644 --- a/outlib/TabOptionsFirefox.js +++ b/outlib/TabOptionsFirefox.js @@ -6,7 +6,7 @@ TabOptions = function (_React$Component) {_inherits(TabOptions, _React$Component _this.state = {};return _this; }_createClass(TabOptions, [{ key: "logo", value: function logo() { - var logo = [React.createElement("img", { src: "images/browsers.svg", style: { maxWidth: "3rem" } }), React.createElement("h2", null, "Tab Manager Plus ", "5.2.0")]; + var logo = [React.createElement("img", { src: "images/browsers.svg", style: { maxWidth: "3rem" } }), React.createElement("h2", null, "Tab Manager Plus ", "5.2.1")]; return ( React.createElement("div", { className: "logo-options" }, diff --git a/outlib/Window.js b/outlib/Window.js index b3441c58..b47564a3 100644 --- a/outlib/Window.js +++ b/outlib/Window.js @@ -343,17 +343,22 @@ Window = function (_React$Component) {_inherits(Window, _React$Component); this.state.windowTitles = []; this.state.tabs = tabs.length + this.props.window.id * 99; for (var i = 0; i < tabs.length; i++) { + if (!!tabs[i].props && !!tabs[i].props.tab && !!tabs[i].props.tab.url) { var url = new URL(tabs[i].props.tab.url); - var protocol = url.protocol; - var hostname = url.hostname; - if (protocol.indexOf("chrome-extension") > -1) { - hostname = tabs[i].props.tab.title; + var protocol = url.protocol || ""; + var hostname = url.hostname || ""; + if (protocol.indexOf("view-source") > -1 && !!url.pathname) { + url = new URL(url.pathname); + hostname = url.hostname || "source"; + } else if (protocol.indexOf("chrome-extension") > -1) { + hostname = tabs[i].props.tab.title || "extension"; } else if (protocol.indexOf("about") > -1) { - hostname = tabs[i].props.tab.title; + hostname = tabs[i].props.tab.title || "about"; } else if (hostname.indexOf("mail.google") > -1) { hostname = "gmail"; } else { + if (!hostname) hostname = ""; hostname = hostname.replace("www.", ""); var regex_var = new RegExp(/(\.[^\.]{0,2})(\.[^\.]{0,2})(\.*$)|(\.[^\.]*)(\.*$)/); hostname = hostname. @@ -361,13 +366,28 @@ Window = function (_React$Component) {_inherits(Window, _React$Component); split("."). pop(); } - if (hostname.length > 18) { - hostname = tabs[i].props.tab.title; + + if (!!hostname && hostname.length > 18) { + hostname = tabs[i].props.tab.title || ""; + + while (hostname.length > 18 && hostname.indexOf("—") > -1) { + hostname = hostname.split("—"); + hostname.pop(); + hostname = hostname.join("—"); + } + + while (hostname.length > 18 && hostname.indexOf("-") > -1) { + hostname = hostname.split("-"); + hostname.pop(); + hostname = hostname.join("-"); + } + while (hostname.length > 18 && hostname.indexOf(" ") > -1) { hostname = hostname.split(" "); hostname.pop(); hostname = hostname.join(" "); } + } this.state.windowTitles.push(hostname); }