diff --git a/background.js b/background.js
index 5d0c42af..6cbb809c 100644
--- a/background.js
+++ b/background.js
@@ -199,16 +199,23 @@ function tabUpdated(tabId, changeInfo, tabInfo){
if (url && !url.startsWith('chrome://')) {
const date = Date.now();
console.log(`Tab: ${tabId} URL changed to ${url} at ${date}`);
- readPage(tabId);
+ // readPage(tabId);
+ setupAnnotation(tabId);
}
}
+function setupAnnotation(tabId) {
+ browser.scripting.executeScript({ // this works. Don't touch.
+ target: { tabId: tabId },
+ files: ['lib/content.js']
+ })
+}
+
function readPage(tabId){
browser.scripting.executeScript({ // this works. Don't touch.
- target: { tabId: tab.id },
- func: ['readPage.js']
+ target: { tabId: tabId },
+ files: ['lib/readPage.js']
})
-
}
function logRequest(details){
@@ -513,6 +520,14 @@ browser.runtime.onMessage.addListener(function(request, sender, sendResponse) {
let payload = request.result;
console.log(payload);
}
+ else if (request.from === "content") {
+ // sent the data (hilighted text and url) to the lib/annotation.jsx
+ chrome.runtime.sendMessage( {
+ command: 'sent_annotation',
+ highlighted_text: request.result,
+ url: request.url,
+ });
+ }
else if (request.command === "update_settings"){
let settings = request.params
if (settings.name === "openInOwnTab"){ setupPopup(settings.value); }
@@ -617,8 +632,6 @@ async function openExtension(){
await browser.action.openPopup();
}
-
-
// setInterval(setupListeners, 300000);
// setupListeners();
setup();
diff --git a/lib/TabManager.jsx b/lib/TabManager.jsx
index 1a140517..33c29f3f 100644
--- a/lib/TabManager.jsx
+++ b/lib/TabManager.jsx
@@ -115,7 +115,8 @@ class TabManager extends React.Component {
optionsActive: !!this.props.optionsActive,
filterTabs: filterTabs,
dupTabs: false,
- colorsActive: false
+ colorsActive: false,
+ annotations: []
};
this.addWindow = this.addWindow.bind(this);
@@ -148,6 +149,7 @@ class TabManager extends React.Component {
this.fuzzySearch = this.fuzzySearch.bind(this);
this.sessionsText = this.sessionsText.bind(this);
this.sessionSync = this.sessionSync.bind(this);
+ this.receiveMessage = this.receiveMessage.bind(this);
this.tabActionsText = this.tabActionsText.bind(this);
this.tabHeightText = this.tabHeightText.bind(this);
this.tabLimitText = this.tabLimitText.bind(this);
@@ -206,6 +208,7 @@ class TabManager extends React.Component {
//this.update();
this.forceUpdate();
}
+
render() {
var _this = this;
@@ -514,6 +517,7 @@ class TabManager extends React.Component {
+
);
}
@@ -535,6 +539,7 @@ class TabManager extends React.Component {
browser.windows.onRemoved.addListener(runUpdate);
browser.storage.onChanged.addListener(this.sessionSync);
+ browser.runtime.onMessage.addListener(this.receiveMessage)
this.sessionSync();
@@ -557,6 +562,18 @@ class TabManager extends React.Component {
// box.select();
// box.focus();
}
+
+ receiveMessage(message, sender, sendResponse) {
+ if(message.command === 'sent_annotation'){
+ console.log(message.highlighted_text);
+ console.log(message.url);
+
+ this.state.annotations.push({
+ url: message.url,
+ annotation: message.highlighted_text
+ });
+ }
+ }
async sessionSync() {
var values = await browser.storage.local.get(null);
@@ -806,13 +823,15 @@ class TabManager extends React.Component {
return;
}
let tabs = Object.values(this.state.tabsbyid);
- console.log(tabs);
+ console.log("hello kihoon");
+ console.log(tabs[0]);
const fuse = new Fuse(
tabs,
{
keys: [
{name: 'title', weight: 0.6},
- {name: 'url', weight: 0.4}
+ {name: 'url', weight: 0.4},
+ // {name: 'annotations', weight: 0.3}
],
includeScore: true ,
includesMatches: true,
diff --git a/lib/content.js b/lib/content.js
new file mode 100644
index 00000000..3ad91827
--- /dev/null
+++ b/lib/content.js
@@ -0,0 +1,35 @@
+const mediumHighlighter1 = document.createElement("medium-highlighter");
+document.body.appendChild(mediumHighlighter1);
+
+const setMarkerPosition = (markerPosition) =>
+ mediumHighlighter1.setAttribute(
+ "markerPosition",
+ JSON.stringify(markerPosition)
+ );
+
+const getSelectedText = () => window.getSelection().toString();
+
+document.addEventListener("click", () => {
+ if (getSelectedText().length > 0) {
+ setMarkerPosition(getMarkerPosition());
+ }
+});
+
+document.addEventListener("selectionchange", () => {
+ if (getSelectedText().length === 0) {
+ setMarkerPosition({ display: "none" });
+ }
+});
+
+function getMarkerPosition() {
+ const rangeBounds = window
+ .getSelection()
+ .getRangeAt(0)
+ .getBoundingClientRect();
+ return {
+ // Substract width of marker button -> 40px / 2 = 20
+ left: rangeBounds.left + rangeBounds.width / 2 - 35,
+ top: rangeBounds.top - 70,
+ display: "flex",
+ };
+}
diff --git a/lib/medium-highlighter.js b/lib/medium-highlighter.js
new file mode 100644
index 00000000..0edb692b
--- /dev/null
+++ b/lib/medium-highlighter.js
@@ -0,0 +1,139 @@
+const highlightColor = "rgb(255, 255, 0)";
+// test
+const template = `
+
+
+
+
+
+`;
+
+const styled = ({ display = "none", left = 0, top = 0 }) => `
+ #mediumHighlighter {
+ align-items: center;
+ background-color: black;
+ border-radius: 5px;
+ border: none;
+ cursor: pointer;
+ display: ${display};
+ justify-content: center;
+ left: ${left}px;
+ padding: 5px 10px;
+ position: fixed;
+ top: ${top}px;
+ width: 70px;
+ z-index: 9999;
+ }
+ .text-marker {
+ fill: white;
+ }
+ .text-marker:hover {
+ fill: ${highlightColor};
+ }
+`;
+
+class MediumHighlighter extends HTMLElement {
+ constructor() {
+ super();
+ this.render();
+ }
+
+ get markerPosition() {
+ return JSON.parse(this.getAttribute("markerPosition") || "{}");
+ }
+
+ get styleElement() {
+ return this.shadowRoot.querySelector("style");
+ }
+
+ get highlightTemplate() {
+ return this.shadowRoot.getElementById("highlightTemplate");
+ }
+
+ static get observedAttributes() {
+ return ["markerPosition"];
+ }
+
+ render() {
+ this.attachShadow({ mode: "open" });
+ const style = document.createElement("style");
+ style.textContent = styled({});
+ this.shadowRoot.appendChild(style);
+ this.shadowRoot.innerHTML += template;
+ this.shadowRoot
+ .getElementById("mediumHighlighter")
+ .addEventListener("click", () => this.highlightSelection());
+ }
+
+ attributeChangedCallback(name, oldValue, newValue) {
+ if (name === "markerPosition") {
+ this.styleElement.textContent = styled(this.markerPosition);
+ }
+ }
+
+ highlightSelection() {
+ var userSelection = window.getSelection();
+ for (let i = 0; i < userSelection.rangeCount; i++) {
+ this.highlightRange(userSelection.getRangeAt(i));
+ }
+ var browser = chrome || browser;
+ browser.runtime.sendMessage({
+ from: "content",
+ result: userSelection.toString(),
+ url: document.querySelector("a").href
+ })
+ window.getSelection().empty();
+ }
+
+ highlightRange(range) {
+ const clone =
+ this.highlightTemplate.cloneNode(true).content.firstElementChild;
+ clone.appendChild(range.extractContents());
+ range.insertNode(clone);
+ }
+}
+
+window.customElements.define("medium-highlighter", MediumHighlighter);
\ No newline at end of file
diff --git a/lib/webcomponents-bundle.js b/lib/webcomponents-bundle.js
new file mode 100644
index 00000000..e69de29b
diff --git a/manifest.json b/manifest.json
index 048f429b..c5d74b60 100644
--- a/manifest.json
+++ b/manifest.json
@@ -15,11 +15,13 @@
},
"permissions": [
"tabs",
+ "activeTab",
"contextMenus",
"storage",
"tabGroups",
"windows",
- "webRequest"
+ "webRequest",
+ "scripting"
],
"host_permissions":[
"*://*/*"
@@ -27,7 +29,10 @@
"content_scripts":[
{
"matches": ["*://*/*"],
- "js": ["lib/readPage.js"]
+ "js": [
+ "node_modules/@webcomponents/custom-elements/custom-elements.min.js",
+ "lib/medium-highlighter.js",
+ "lib/content.js"]
}
],
"optional_permissions": [
diff --git a/outlib/Session.js b/outlib/Session.js
deleted file mode 100644
index 26c246fe..00000000
--- a/outlib/Session.js
+++ /dev/null
@@ -1,251 +0,0 @@
-"use strict";var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};}function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;}var
-
-Session = function (_React$Component) {_inherits(Session, _React$Component);
- function Session(props) {_classCallCheck(this, Session);
-
- //console.log(this.props.window);
- //console.log(this.props.window.name);
- var _this3 = _possibleConstructorReturn(this, (Session.__proto__ || Object.getPrototypeOf(Session)).call(this, props));var name = _this3.props.window.name;
- _this3.state = {
- windowTitles: [],
- name: name,
- tabs: 0 };
-
-
- _this3.stop = _this3.stop.bind(_this3);
- _this3.windowClick = _this3.windowClick.bind(_this3);
- _this3.close = _this3.close.bind(_this3);
- _this3.maximize = _this3.maximize.bind(_this3);return _this3;
-
- }_createClass(Session, [{ key: "render", value: function render()
- {
- var _this = this;
- var name = this.props.window.name;
- var hideWindow = true;
- var titleAdded = false;
- var tabsperrow = this.props.layout.indexOf("blocks") > -1 ? Math.ceil(Math.sqrt(this.props.tabs.length + 2)) : this.props.layout == "vertical" ? 1 : 15;
- var tabs = this.props.tabs.map(function (tab) {
- var tabId = tab.id * tab.id * tab.id * 100;
- var isHidden = !!_this.props.hiddenTabs[tabId] && _this.props.filterTabs;
- var isSelected = !!_this.props.selection[tabId];
- tab.id = tabId;
- hideWindow &= isHidden;
- return (
- React.createElement(Tab, {
- key: "sessiontab_" + _this.props.window.id + "_" + tab.index,
- window: _this.props.window,
- layout: _this.props.layout,
- tab: tab,
- selected: isSelected,
- hidden: isHidden,
- middleClick: _this.props.tabMiddleClick,
- hoverHandler: _this.props.hoverHandler,
- searchActive: _this.props.searchActive,
- select: _this.props.select,
- ref: "sessiontab" + tabId,
- id: "sessiontab-" + tab.id }));
-
-
- });
- if (!hideWindow) {
- if (!!this.props.tabactions) {
- tabs.push(
- React.createElement("div", { className: "newliner" }),
- React.createElement("div", { className: "window-actions" },
- React.createElement("div", {
- className: "icon tabaction restore " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Restore this saved window\nWill restore " + tabs.length + " tabs. Please note : The tabs will be restored without their history.",
- onClick: this.windowClick,
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction delete " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Delete this saved window\nWill delete " + tabs.length + " tabs permanently",
- onClick: this.close,
- onMouseEnter: this.props.hoverIcon })));
-
-
-
- }
-
- if (this.props.windowTitles) {
- if (name) {
- tabs.unshift(
- React.createElement("h3", { key: "session-" + this.props.window.id + "-windowTitle", className: "center windowTitle" },
- name));
-
-
- titleAdded = true;
- }
- }
- if (tabsperrow < 3) {
- tabsperrow = 3;
- }
- var children = [];
- if (!!titleAdded) {
- children.push(tabs.shift());
- }
- for (var j = 0; j < tabs.length; j++) {
- children.push(tabs[j]);
- if ((j + 1) % tabsperrow == 0 && j && this.props.layout.indexOf("blocks") > -1) {
- children.push(React.createElement("div", { className: "newliner" }));
- }
- }
- var focused = false;
- if (this.props.window.windowsInfo.focused || this.props.lastOpenWindow == this.props.window.windowsInfo.id) {
- focused = true;
- }
- return (
- React.createElement("div", {
- key: "session-" + this.props.window.id,
- id: "session-" + this.props.window.id,
- className:
- "window " +
- this.props.window.windowsInfo.state +
- " " + (
- focused ? "activeWindow" : "") +
- " session " + (
- this.props.layout.indexOf("blocks") > -1 ? "block" : "") +
- " " +
- this.props.layout +
- " " + (
- this.props.window.windowsInfo.incognito ? " incognito" : "") +
- " " + (
- focused ? " focused" : ""),
-
- onClick: this.windowClick },
-
- React.createElement("div", { className: "windowcontainer" }, children)));
-
-
- } else {
- return null;
- }
- } }, { key: "shouldComponentUpdate", value: function shouldComponentUpdate(
- nextProps, nextState) {
- //console.log("should update?", nextProps, nextState);
- return true;
- } }, { key: "stop", value: function stop(
- e) {
- e.stopPropagation();
- } }, { key: "windowClick", value: function () {var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(
- e) {var _this2, customName, whitelistWindow, whitelistTab, filteredWindow, newWindow, emptyTab, i, newTab, tabCreated, names;return regeneratorRuntime.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:
- _this2 = this;
- e.stopPropagation();
- console.log("source window", this.props.window);
- // chrome.runtime.getBackgroundPage(function callback(tabs, backgroundPage) {
- // backgroundPage.createWindowWithTabs(tabs);
- // }.bind(null, this.props.window.tabs));
-
- customName = false;
- if (this.props.window && this.props.window.name && this.props.window.customName) {
- customName = this.props.window.name;
- }
-
- whitelistWindow = ["left", "top", "width", "height", "incognito", "type"];
-
- if (navigator.userAgent.search("Firefox") > -1) {
- whitelistWindow = ["left", "top", "width", "height", "incognito", "type"];
- }
-
- whitelistTab = ["url", "active", "selected", "pinned"];
-
- if (navigator.userAgent.search("Firefox") > -1) {
- whitelistTab = ["url", "active", "pinned"];
- }
-
- filteredWindow = Object.keys(this.props.window.windowsInfo).
- filter(function (key) {
- return whitelistWindow.includes(key);
- }).
- reduce(function (obj, key) {
- obj[key] = _this2.props.window.windowsInfo[key];
- return obj;
- }, {});
- console.log("filtered window", filteredWindow);_context.next = 13;return (
-
- browser.windows.create(filteredWindow).catch(function (error) {
- console.error(error);
- console.log(error);
- console.log(error.message);
- }));case 13:newWindow = _context.sent;
-
- emptyTab = newWindow.tabs[0].id;
-
- i = 0;case 16:if (!(i < this.props.window.tabs.length)) {_context.next = 27;break;}
- newTab = Object.keys(this.props.window.tabs[i]).
- filter(function (key) {
- return whitelistTab.includes(key);
- }).
- reduce(function (obj, key) {
- obj[key] = _this2.props.window.tabs[i][key];
- return obj;
- }, {});
- console.log("source tab", newTab);
- if (navigator.userAgent.search("Firefox") > -1) {
- if (!!newTab.url && newTab.url.search("about:") > -1) {
- console.log("filtered by about: url", newTab.url);
- newTab.url = "";
- }
- }
- newTab.windowId = newWindow.id;_context.next = 23;return (
- browser.tabs.create(newTab).catch(function (error) {
- console.error(error);
- console.log(error);
- console.log(error.message);
- }));case 23:tabCreated = _context.sent;case 24:i++;_context.next = 16;break;case 27:_context.next = 29;return (
-
-
- browser.tabs.remove(emptyTab).catch(function (error) {
- console.error(error);
- console.log(error);
- console.log(error.message);
- }));case 29:
-
- if (customName) {
- names = localStorage["windowNames"];
- if (!!names) {
- names = JSON.parse(names);
- } else {
- names = {};
- }
- names[newWindow.id] = customName || "";
- localStorage["windowNames"] = JSON.stringify(names);
- }
-
- this.props.parentUpdate();
-
- if (!!window.inPopup) {
- window.close();
- } else {
- setTimeout(function () {
- this.props.scrollTo("window", newWindow.id);
- }.bind(this), 250);
- }
-
- // , function (tabs, w) {
- // browser.tabs.create(first.id, { pinned: first.pinned });
- // if (t.length > 0) {
- // browser.tabs.move(t, { windowId: w.id, index: -1 }, function (tab) {
- // browser.tabs.update(tab.id, { pinned: tab.pinned });
- // });
- // }
- // browser.windows.update(w.id, { focused: true });
- // }.bind(null, this.props.window.tabs));
- // browser.windows.update(this.props.window.windowsInfo.id, {
- // "focused": true },
- // function (a) {this.props.parentUpdate();}.bind(this));
- case 32:case "end":return _context.stop();}}}, _callee, this);}));function windowClick(_x) {return _ref.apply(this, arguments);}return windowClick;}() }, { key: "close", value: function () {var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(
- e) {var value;return regeneratorRuntime.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:
- e.stopPropagation();_context2.next = 3;return (
- browser.storage.local.remove(this.props.window.id));case 3:value = _context2.sent;
- console.log(value);
- this.props.parentUpdate();
- // browser.windows.remove(this.props.window.windowsInfo.id);
- case 6:case "end":return _context2.stop();}}}, _callee2, this);}));function close(_x2) {return _ref2.apply(this, arguments);}return close;}() }, { key: "maximize", value: function maximize(
- e) {
- e.stopPropagation();
- // browser.windows.update(this.props.window.windowsInfo.id, {
- // "state": "normal" },
- // function (a) {this.props.parentUpdate();}.bind(this));
- } }]);return Session;}(React.Component);
\ No newline at end of file
diff --git a/outlib/Tab.js b/outlib/Tab.js
deleted file mode 100644
index 1c4e4096..00000000
--- a/outlib/Tab.js
+++ /dev/null
@@ -1,214 +0,0 @@
-"use strict";var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};}function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;}var
-
-Tab = function (_React$Component) {_inherits(Tab, _React$Component);
- function Tab(props) {_classCallCheck(this, Tab);var _this = _possibleConstructorReturn(this, (Tab.__proto__ || Object.getPrototypeOf(Tab)).call(this,
- props));
- _this.state = {
- favIcon: "" };
-
-
- _this.onHover = _this.onHover.bind(_this);
- _this.onMouseDown = _this.onMouseDown.bind(_this);
- _this.click = _this.click.bind(_this);
- _this.dragStart = _this.dragStart.bind(_this);
- _this.dragOver = _this.dragOver.bind(_this);
- _this.dragOut = _this.dragOut.bind(_this);
- _this.drop = _this.drop.bind(_this);
- _this.resolveFavIconUrl = _this.resolveFavIconUrl.bind(_this);return _this;
-
- }_createClass(Tab, [{ key: "componentWillMount", value: function componentWillMount()
- {
- this.resolveFavIconUrl();
- } }, { key: "render", value: function render()
- {
- var children = [];
- if (this.props.layout == "vertical") {
- children.push(
- React.createElement("div", { key: "tab-pinned-" + this.props.tab.id, className: "tab-pinned " + (!this.props.tab.pinned ? "hidden" : "") }, "Pinned"));
-
-
-
- children.push(
- React.createElement("div", { key: "tab-highlighted-" + this.props.tab.id, className: "tab-highlighted " + (!this.props.tab.highlighted ? "hidden" : "") }, "Active"));
-
-
-
- children.push(
- React.createElement("div", { key: "tab-selected-" + this.props.tab.id, className: "tab-selected " + (!this.props.selected ? "hidden" : "") }, "Selected"));
-
-
-
- children.push(
- React.createElement("div", {
- key: "tab-icon-" + this.props.tab.id,
- className: "iconoverlay ",
- style: {
- backgroundImage: this.state.favIcon } }));
-
-
-
- children.push(
- React.createElement("div", { key: "tab-title-" + this.props.tab.id, className: "tabtitle" },
- this.props.tab.title));
-
-
- }
-
- var tabDom = {
- className:
- "icon tab " + (
- this.props.selected ? "selected " : "") + (
- this.props.tab.pinned ? "pinned " : "") + (
- this.props.tab.highlighted ? "highlighted " : "") + (
- this.props.hidden ? "hidden " : "") + (
- this.props.tab.mutedInfo && this.props.tab.mutedInfo.muted ? "muted " : "") + (
- this.props.tab.audible ? "audible " : "") + (
- this.props.tab.discarded ? "discarded " : "") + (
- this.props.layout == "vertical" ? "full " : "") + (
- this.props.tab.incognito ? "incognito " : "") + (
- this.state.draggingOver || "") + (
- this.props.searchActive ? "search-active " : "") +
- " tab-" +
- this.props.tab.id +
- " " + (
- this.props.layout == "vertical" ? "vertical " : "blocks "),
- style:
- this.props.layout == "vertical" ?
- {} :
- { backgroundImage: this.state.favIcon },
-
-
- id: this.props.id,
- title: this.props.tab.title,
- onClick: this.click,
- onMouseDown: this.onMouseDown,
- onMouseEnter: this.onHover };
-
-
- if (!!this.props.drag) {
- tabDom["onDragStart"] = this.dragStart;
- tabDom["onDragOver"] = this.dragOver;
- tabDom["onDragLeave"] = this.dragOut;
- tabDom["onDrop"] = this.drop;
- tabDom["draggable"] = "true";
- }
-
- return (
- React.createElement("div", tabDom,
- children,
- React.createElement("div", { className: "limiter" })));
-
-
- } }, { key: "onHover", value: function onHover(
- e) {
- this.props.hoverHandler(this.props.tab);
- this.resolveFavIconUrl();
- } }, { key: "onMouseDown", value: function onMouseDown(
- e) {
- if (e.button === 0) return;
- if (!this.props.drag) return;
- this.click(e);
- } }, { key: "click", value: function () {var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(
- e) {var tabId, windowId, backgroundPage;return regeneratorRuntime.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:if (
- this.props.drag) {_context.next = 2;break;}return _context.abrupt("return");case 2:
- this.stopProp(e);
-
- tabId = this.props.tab.id;
- windowId = this.props.window.id;if (!(
-
- e.button === 1)) {_context.next = 9;break;}
- this.props.middleClick(tabId);_context.next = 19;break;case 9:if (!(
- e.button === 2 || e.nativeEvent.metaKey || e.nativeEvent.altKey || e.nativeEvent.shiftKey || e.nativeEvent.ctrlKey)) {_context.next = 14;break;}
- e.preventDefault();
- if (e.button === 2 && (e.nativeEvent.metaKey || e.nativeEvent.altKey || e.nativeEvent.shiftKey || e.nativeEvent.ctrlKey)) {
- this.props.selectTo(tabId);
- } else {
- this.props.select(tabId);
- }_context.next = 19;break;case 14:_context.next = 16;return (
-
- browser.runtime.getBackgroundPage());case 16:backgroundPage = _context.sent;
- if (navigator.userAgent.search("Firefox") > -1) {
- backgroundPage.focusOnTabAndWindowDelayed({ id: tabId, windowId: windowId });
- } else {
- backgroundPage.focusOnTabAndWindow({ id: tabId, windowId: windowId });
- }
- if (!!window.inPopup) window.close();case 19:return _context.abrupt("return",
-
- false);case 20:case "end":return _context.stop();}}}, _callee, this);}));function click(_x) {return _ref.apply(this, arguments);}return click;}() }, { key: "dragStart", value: function dragStart(
-
- e) {
- if (!!this.props.drag) {
- e.dataTransfer.setData("Text", this.props.tab.id);
- e.dataTransfer.setData("text/uri-list", this.props.tab.url);
- this.props.drag(e, this.props.tab.id);
- } else {
- return false;
- }
- } }, { key: "dragOver", value: function dragOver(
- e) {
- this.stopProp(e);
- if (!this.props.drag) return;
- var before = this.state.draggingOver;
- if (this.props.layout == "vertical") {
- this.state.draggingOver = e.nativeEvent.offsetY > ReactDOM.findDOMNode(this).clientHeight / 2 ? "bottom" : "top";
- } else {
- this.state.draggingOver = e.nativeEvent.offsetX > ReactDOM.findDOMNode(this).clientWidth / 2 ? "right" : "left";
- }
- if (before != this.state.draggingOver) this.forceUpdate();
- } }, { key: "dragOut", value: function dragOut()
- {
- if (!this.props.drag) return;
- delete this.state.draggingOver;
- this.forceUpdate();
- } }, { key: "drop", value: function drop(
- e) {
- if (!!this.props.drop) {
- this.stopProp(e);
- var before = this.state.draggingOver == "top" || this.state.draggingOver == "left";
- delete this.state.draggingOver;
- this.props.drop(this.props.tab.id, before);
- } 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:
-
-
- // firefox screenshots; needs
- // if(!!browser.tabs.captureTab) {
- // console.log("tabs captureTab");
- // 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) {
- // chrome screenshots / only for active tabs; needs
- // if(!!browser.tabs.captureVisibleTab && this.props.tab.highlighted) {
- // console.log("tabsCapture");
- // try {
- // image = await browser.tabs.captureVisibleTab( this.props.window.id, {} );
- // //console.log(image);
- // } catch ( e ) {
- // console.log(e.message);
- // }
- // image = "url(" + image + ")";
- // }else{
- image = this.props.tab.favIconUrl ? "url(" + this.props.tab.favIconUrl + ")" : "";
- //}
- } else {
- favIcons = ["bookmarks", "chrome", "crashes", "downloads", "extensions", "flags", "history", "settings"];
- iconName = this.props.tab.url.slice(9).match(/^\w+/g);
- image = !iconName || favIcons.indexOf(iconName[0]) < 0 ? "" : "url(../images/chrome/" + iconName[0] + ".png)";
- }
- this.setState({
- favIcon: image });case 2:case "end":return _context2.stop();}}}, _callee2, this);}));function resolveFavIconUrl() {return _ref2.apply(this, arguments);}return resolveFavIconUrl;}() }, { key: "stopProp", value: function stopProp(
-
-
- e) {
- if (e && e.nativeEvent) {
- e.nativeEvent.preventDefault();
- e.nativeEvent.stopPropagation();
- }
- if (e && e.preventDefault) {
- e.preventDefault();
- e.stopPropagation();
- }
- } }]);return Tab;}(React.Component);
\ No newline at end of file
diff --git a/outlib/TabManager.js b/outlib/TabManager.js
deleted file mode 100644
index 96a1cd76..00000000
--- a/outlib/TabManager.js
+++ /dev/null
@@ -1,1774 +0,0 @@
-"use strict";var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};}function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;}
-
-var browser = browser || chrome;var
-
-TabManager = function (_React$Component) {_inherits(TabManager, _React$Component);
- function TabManager(props) {_classCallCheck(this, TabManager);
-
- //this.update();
- var _this7 = _possibleConstructorReturn(this, (TabManager.__proto__ || Object.getPrototypeOf(TabManager)).call(this, props));
- if (navigator.userAgent.search("Firefox") > -1) {
- } else {
- var check = browser.permissions.contains({ permissions: ["system.display"] });
- check.then(
- function (result) {
- if (result) {
- // The extension has the permissions.
- } else {
- localStorage["hideWindows"] = "0";
- this.state.hideWindows = false;
- }
- }.bind(_this7));
-
- }
-
- var layout = "blocks";
- var animations = true;
- var windowTitles = true;
- var compact = false;
- var dark = false;
- var tabactions = true;
- var badge = true;
- var sessionsFeature = false;
- var hideWindows = false;
- var filterTabs = false;
- var tabLimit = 0;
- var openInOwnTab = false;
- var tabWidth = 800;
- var tabHeight = 600;
-
- if (_this7.localStorageAvailable()) {
- if (!localStorage["layout"]) localStorage["layout"] = "blocks";
- if (typeof localStorage["tabLimit"] === "undefined") localStorage["tabLimit"] = "0";
- if (typeof localStorage["openInOwnTab"] === "undefined") localStorage["openInOwnTab"] = "0";
- if (typeof localStorage["tabWidth"] === "undefined") localStorage["tabWidth"] = "800";
- if (typeof localStorage["tabHeight"] === "undefined") localStorage["tabHeight"] = "600";
- if (typeof localStorage["animations"] === "undefined") localStorage["animations"] = "1";
- if (typeof localStorage["windowTitles"] === "undefined") localStorage["windowTitles"] = "1";
- if (typeof localStorage["compact"] === "undefined") localStorage["compact"] = "0";
- if (typeof localStorage["dark"] === "undefined") localStorage["dark"] = "0";
- if (typeof localStorage["tabactions"] === "undefined") localStorage["tabactions"] = "1";
- if (typeof localStorage["badge"] === "undefined") localStorage["badge"] = "1";
- 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";
-
- layout = localStorage["layout"];
- tabLimit = JSON.parse(localStorage["tabLimit"]);
- tabWidth = JSON.parse(localStorage["tabWidth"]);
- tabHeight = JSON.parse(localStorage["tabHeight"]);
- openInOwnTab = _this7.toBoolean(localStorage["openInOwnTab"]);
- animations = _this7.toBoolean(localStorage["animations"]);
- windowTitles = _this7.toBoolean(localStorage["windowTitles"]);
- compact = _this7.toBoolean(localStorage["compact"]);
- dark = _this7.toBoolean(localStorage["dark"]);
- tabactions = _this7.toBoolean(localStorage["tabactions"]);
- badge = _this7.toBoolean(localStorage["badge"]);
- sessionsFeature = _this7.toBoolean(localStorage["sessionsFeature"]);
- hideWindows = _this7.toBoolean(localStorage["hideWindows"]);
- filterTabs = _this7.toBoolean(localStorage["filter-tabs"]);
- }
-
- if (dark) {
- document.body.className = "dark";
- } else {
- document.body.className = "";
- }
-
- // var closeTimeout = setTimeout(function () {
- // window.close();
- // }, 100000);
- var closeTimeout;
- var resetTimeout;
-
- _this7.state = {
- layout: layout,
- animations: animations,
- windowTitles: windowTitles,
- tabLimit: tabLimit,
- openInOwnTab: openInOwnTab,
- tabWidth: tabWidth,
- tabHeight: tabHeight,
- compact: compact,
- dark: dark,
- tabactions: tabactions,
- badge: badge,
- hideWindows: hideWindows,
- sessionsFeature: sessionsFeature,
- lastOpenWindow: -1,
- windows: [],
- sessions: [],
- selection: {},
- lastSelect: false,
- hiddenTabs: {},
- tabsbyid: {},
- windowsbyid: {},
- closeTimeout: closeTimeout,
- resetTimeout: resetTimeout,
- height: 600,
- hasScrollBar: false,
- focusUpdates: 0,
- topText: "",
- bottomText: "",
- lastDirection: false,
- optionsActive: !!_this7.props.optionsActive,
- filterTabs: filterTabs,
- dupTabs: false,
- colorsActive: false };
-
-
- _this7.addWindow = _this7.addWindow.bind(_this7);
- _this7.animationsText = _this7.animationsText.bind(_this7);
- _this7.badgeText = _this7.badgeText.bind(_this7);
- _this7.changelayout = _this7.changelayout.bind(_this7);
- _this7.changeTabHeight = _this7.changeTabHeight.bind(_this7);
- _this7.changeTabLimit = _this7.changeTabLimit.bind(_this7);
- _this7.changeTabWidth = _this7.changeTabWidth.bind(_this7);
- _this7.checkKey = _this7.checkKey.bind(_this7);
- _this7.clearSelection = _this7.clearSelection.bind(_this7);
- _this7.compactText = _this7.compactText.bind(_this7);
- _this7.darkText = _this7.darkText.bind(_this7);
- _this7.deleteTabs = _this7.deleteTabs.bind(_this7);
- _this7.discardTabs = _this7.discardTabs.bind(_this7);
- _this7.donate = _this7.donate.bind(_this7);
- _this7.exportSessions = _this7.exportSessions.bind(_this7);
- _this7.exportSessionsText = _this7.exportSessionsText.bind(_this7);
- _this7.getTip = _this7.getTip.bind(_this7);
- _this7.hideText = _this7.hideText.bind(_this7);
- _this7.highlightDuplicates = _this7.highlightDuplicates.bind(_this7);
- _this7.hoverIcon = _this7.hoverIcon.bind(_this7);
- _this7.importSessions = _this7.importSessions.bind(_this7);
- _this7.importSessionsText = _this7.importSessionsText.bind(_this7);
- _this7.openInOwnTabText = _this7.openInOwnTabText.bind(_this7);
- _this7.pinTabs = _this7.pinTabs.bind(_this7);
- _this7.rateExtension = _this7.rateExtension.bind(_this7);
- _this7.scrollTo = _this7.scrollTo.bind(_this7);
- _this7.search = _this7.search.bind(_this7);
- _this7.sessionsText = _this7.sessionsText.bind(_this7);
- _this7.sessionSync = _this7.sessionSync.bind(_this7);
- _this7.tabActionsText = _this7.tabActionsText.bind(_this7);
- _this7.tabHeightText = _this7.tabHeightText.bind(_this7);
- _this7.tabLimitText = _this7.tabLimitText.bind(_this7);
- _this7.tabWidthText = _this7.tabWidthText.bind(_this7);
- _this7.toggleAnimations = _this7.toggleAnimations.bind(_this7);
- _this7.toggleBadge = _this7.toggleBadge.bind(_this7);
- _this7.toggleCompact = _this7.toggleCompact.bind(_this7);
- _this7.toggleDark = _this7.toggleDark.bind(_this7);
- _this7.toggleFilterMismatchedTabs = _this7.toggleFilterMismatchedTabs.bind(_this7);
- _this7.toggleHide = _this7.toggleHide.bind(_this7);
- _this7.toggleOpenInOwnTab = _this7.toggleOpenInOwnTab.bind(_this7);
- _this7.toggleOptions = _this7.toggleOptions.bind(_this7);
- _this7.toggleSessions = _this7.toggleSessions.bind(_this7);
- _this7.toggleTabActions = _this7.toggleTabActions.bind(_this7);
- _this7.toggleWindowTitles = _this7.toggleWindowTitles.bind(_this7);
- _this7.update = _this7.update.bind(_this7);
- _this7.windowTitlesText = _this7.windowTitlesText.bind(_this7);return _this7;
-
- }_createClass(TabManager, [{ key: "componentWillMount", value: function componentWillMount()
- {
- this.update();
- } }, { key: "hoverHandler", value: function hoverHandler(
- tab) {
- this.setState({ topText: tab.title });
- this.setState({ bottomText: tab.url });
- // clearTimeout(this.state.closeTimeout);
- // this.state.closeTimeout = setTimeout(function () {
- // window.close();
- // }, 100000);
- clearTimeout(this.state.resetTimeout);
- this.state.resetTimeout = setTimeout(
- function () {
- this.setState({ topText: "", bottomText: "" });
- this.update();
- }.bind(this),
- 15000);
-
- //this.update();
- } }, { key: "hoverIcon", value: function hoverIcon(
- e) {
- var text = "";
- if (e && e.target && e.target.title) {
- text = e.target.title;
- }
- var bottom = " ";
- if (text.indexOf("\n") > -1) {
- var a = text.split("\n");
- text = a[0];
- bottom = a[1];
- }
- this.setState({ topText: text });
- this.setState({ bottomText: bottom });
- //this.update();
- this.forceUpdate();
- } }, { key: "render", value: function render()
- {
- var _this = this;
-
- var hiddenCount = this.state.hiddenCount || 0;
- var tabCount = this.state.tabCount || 0;
-
- var haveMin = false;
- var haveSess = false;
-
- for (var i = this.state.windows.length - 1; i >= 0; i--) {
- if (this.state.windows[i].state == "minimized") haveMin = true;
- }
-
- if (this.state.sessionsFeature) {
- if (this.state.sessions.length > 0) haveSess = true;
- // disable session window if we have filtering enabled
- // and filter active
- if (haveSess && this.state.filterTabs) {
- if (this.state.searchLen > 0 || Object.keys(this.state.hiddenTabs).length > 0) {
- haveSess = false;
- }
- }
- }
-
- return (
- React.createElement("div", {
- id: "root",
- className:
- (this.state.compact ? "compact" : "") +
- " " + (
- this.state.animations ? "animations" : "no-animations") +
- " " + (
- this.state.windowTitles ? "windowTitles" : "no-windowTitles"),
-
- onKeyDown: this.checkKey,
- ref: "root",
- tabIndex: 0 },
-
- React.createElement("div", { className: "window-container " + this.state.layout + " " + (this.state.optionsActive ? "hidden" : ""), ref: "windowcontainer", tabIndex: 2 },
- this.state.windows.map(function (window) {
- if (window.state == "minimized") return;
- if (!!this.state.colorsActive && this.state.colorsActive !== window.id) return;
- return (
- React.createElement(Window, {
- key: "window" + window.id,
- window: window,
- tabs: window.tabs,
- incognito: window.incognito,
- layout: _this.state.layout,
- selection: _this.state.selection,
- searchActive: _this.state.searchLen > 0,
- sessionsFeature: _this.state.sessionsFeature,
- tabactions: _this.state.tabactions,
- hiddenTabs: _this.state.hiddenTabs,
- filterTabs: _this.state.filterTabs,
- hoverHandler: _this.hoverHandler.bind(_this),
- scrollTo: _this.scrollTo.bind(_this),
- hoverIcon: _this.hoverIcon.bind(_this),
- parentUpdate: _this.update.bind(_this),
- toggleColors: _this.toggleColors.bind(_this),
- tabMiddleClick: _this.deleteTab.bind(_this),
- select: _this.select.bind(_this),
- selectTo: _this.selectTo.bind(_this),
- drag: _this.drag.bind(_this),
- drop: _this.drop.bind(_this),
- dropWindow: _this.dropWindow.bind(_this),
- windowTitles: _this.state.windowTitles,
- lastOpenWindow: _this.state.lastOpenWindow,
- ref: "window" + window.id }));
-
-
- }.bind(this)),
- React.createElement("div", { className: "hrCont " + (!haveMin ? "hidden" : "") },
- React.createElement("div", { className: "hrDiv" },
- React.createElement("span", { className: "hrSpan" }, "Minimized windows"))),
-
-
- this.state.windows.map(function (window) {
- if (window.state !== "minimized") return;
- if (!!this.state.colorsActive && this.state.colorsActive !== window.id) return;
- return (
- React.createElement(Window, {
- key: "window" + window.id,
- window: window,
- tabs: window.tabs,
- incognito: window.incognito,
- layout: _this.state.layout,
- selection: _this.state.selection,
- searchActive: _this.state.searchLen > 0,
- sessionsFeature: _this.state.sessionsFeature,
- tabactions: _this.state.tabactions,
- hiddenTabs: _this.state.hiddenTabs,
- filterTabs: _this.state.filterTabs,
- hoverHandler: _this.hoverHandler.bind(_this),
- scrollTo: _this.scrollTo.bind(_this),
- hoverIcon: _this.hoverIcon.bind(_this),
- parentUpdate: _this.update.bind(_this),
- toggleColors: _this.toggleColors.bind(_this),
- tabMiddleClick: _this.deleteTab.bind(_this),
- select: _this.select.bind(_this),
- selectTo: _this.selectTo.bind(_this),
- drag: _this.drag.bind(_this),
- drop: _this.drop.bind(_this),
- dropWindow: _this.dropWindow.bind(_this),
- windowTitles: _this.state.windowTitles,
- lastOpenWindow: _this.state.lastOpenWindow,
- ref: "window" + window.id }));
-
-
- }.bind(this)),
- React.createElement("div", { className: "hrCont " + (!haveSess ? "hidden" : "") },
- React.createElement("div", { className: "hrDiv" },
- React.createElement("span", { className: "hrSpan" }, "Saved windows"))),
-
-
- haveSess ?
- this.state.sessions.map(function (window) {
- if (!!this.state.colorsActive && this.state.colorsActive !== window.id) return;
- return (
- React.createElement(Session, {
- key: "session" + window.id,
- window: window,
- tabs: window.tabs,
- incognito: window.incognito,
- layout: _this.state.layout,
- selection: _this.state.selection,
- searchActive: _this.state.searchLen > 0,
- tabactions: _this.state.tabactions,
- hiddenTabs: _this.state.hiddenTabs,
- filterTabs: _this.state.filterTabs,
- hoverHandler: _this.hoverHandler.bind(_this),
- scrollTo: _this.scrollTo.bind(_this),
- hoverIcon: _this.hoverIcon.bind(_this),
- parentUpdate: _this.update.bind(_this),
- toggleColors: _this.toggleColors.bind(_this),
- tabMiddleClick: _this.deleteTab.bind(_this),
- select: _this.select.bind(_this),
- windowTitles: _this.state.windowTitles,
- lastOpenWindow: _this.state.lastOpenWindow,
- ref: "session" + window.id }));
-
-
- }.bind(this)) :
- false),
-
- React.createElement("div", { className: "options-container " + (this.state.optionsActive ? "" : "hidden"), ref: "options-container" },
- React.createElement(TabOptions, {
- compact: this.state.compact,
- dark: this.state.dark,
- animations: this.state.animations,
- windowTitles: this.state.windowTitles,
- tabLimit: this.state.tabLimit,
- openInOwnTab: this.state.openInOwnTab,
- tabWidth: this.state.tabWidth,
- tabHeight: this.state.tabHeight,
- tabactions: this.state.tabactions,
- badge: this.state.badge,
- hideWindows: this.state.hideWindows,
- sessionsFeature: this.state.sessionsFeature,
- exportSessions: this.exportSessions,
- importSessions: this.importSessions,
- toggleOpenInOwnTab: this.toggleOpenInOwnTab,
- toggleBadge: this.toggleBadge,
- toggleHide: this.toggleHide,
- toggleSessions: this.toggleSessions,
- toggleAnimations: this.toggleAnimations,
- toggleWindowTitles: this.toggleWindowTitles,
- toggleCompact: this.toggleCompact,
- toggleDark: this.toggleDark,
- toggleTabActions: this.toggleTabActions,
- changeTabLimit: this.changeTabLimit,
- changeTabWidth: this.changeTabWidth,
- changeTabHeight: this.changeTabHeight,
- openInOwnTabText: this.openInOwnTabText,
- badgeText: this.badgeText,
- hideText: this.hideText,
- sessionsText: this.sessionsText,
- exportSessionsText: this.exportSessionsText,
- importSessionsText: this.importSessionsText,
- animationsText: this.animationsText,
- windowTitlesText: this.windowTitlesText,
- tabLimitText: this.tabLimitText,
- tabWidthText: this.tabWidthText,
- tabHeightText: this.tabHeightText,
- compactText: this.compactText,
- darkText: this.darkText,
- tabActionsText: this.tabActionsText,
- getTip: this.getTip })),
-
-
- React.createElement("div", { className: "window top", ref: "tophover" },
- React.createElement("div", { className: "icon windowaction donate", title: "Donate a Coffee", onClick: this.donate, onMouseEnter: this.hoverIcon }),
- React.createElement("div", {
- className: "icon windowaction rate",
- title: "Rate Tab Manager Plus",
- onClick: this.rateExtension,
- onMouseEnter: this.hoverIcon }),
-
- React.createElement("div", { className: "icon windowaction options", title: "Options", onClick: this.toggleOptions, onMouseEnter: this.hoverIcon }),
- React.createElement("input", {
- type: "text",
- disabled: true,
- className: "tabtitle",
- ref: "topbox",
- placeholder: maybePluralize(tabCount, 'tab') + " in " + this.state.windows.length + " windows",
- value: this.state.topText }),
-
- React.createElement("input", { type: "text", disabled: true, className: "taburl", ref: "topboxurl", placeholder: this.getTip(), value: this.state.bottomText })),
-
- React.createElement("div", { className: "window searchbox " + (this.state.optionsActive || !!this.state.colorsActive ? "hidden" : "") },
- React.createElement("table", null,
- React.createElement("tbody", null,
- React.createElement("tr", null,
- React.createElement("td", { className: "one" },
- React.createElement("input", { className: "searchBoxInput", type: "text", placeholder: "Start typing to search tabs...", tabIndex: "1", onChange: this.search, ref: "searchbox" })),
-
- React.createElement("td", { className: "two" },
- React.createElement("div", {
- className: "icon windowaction " + this.state.layout + "-view",
- title: "Change to " + this.readablelayout(this.nextlayout()) + " View",
- onClick: this.changelayout,
- onMouseEnter: this.hoverIcon }),
-
- React.createElement("div", {
- className: "icon windowaction trash",
- title:
- Object.keys(this.state.selection).length > 0 ?
- "Close selected tabs\nWill close " + maybePluralize(Object.keys(this.state.selection).length, 'tab') :
- "Close current Tab",
-
- onClick: this.deleteTabs,
- onMouseEnter: this.hoverIcon }),
-
- React.createElement("div", {
- className: "icon windowaction discard",
- title:
- Object.keys(this.state.selection).length > 0 ?
- "Discard selected tabs\nWill discard " + maybePluralize(Object.keys(this.state.selection).length, 'tab') + " - freeing memory" :
- "Select tabs to discard them and free memory",
-
- style:
- Object.keys(this.state.selection).length > 0 ?
- {} :
- { opacity: 0.25 },
-
- onClick: this.discardTabs,
- onMouseEnter: this.hoverIcon }),
-
- React.createElement("div", {
- className: "icon windowaction pin",
- title:
- Object.keys(this.state.selection).length > 0 ?
- "Pin selected tabs\nWill pin " + maybePluralize(Object.keys(this.state.selection).length, 'tab') :
- "Pin current Tab",
-
- onClick: this.pinTabs,
- onMouseEnter: this.hoverIcon }),
-
- React.createElement("div", {
- className: "icon windowaction filter" + (this.state.filterTabs ? " enabled" : ""),
- title:
- (this.state.filterTabs ? "Turn off hiding of" : "Hide") +
- " tabs that do not match search" + (
- this.state.searchLen > 0 ?
- "\n" + (
- this.state.filterTabs ? "Will reveal " : "Will hide ") +
- maybePluralize(Object.keys(this.state.tabsbyid).length - Object.keys(this.state.selection).length, 'tab') :
- ""),
-
- onClick: this.toggleFilterMismatchedTabs,
- onMouseEnter: this.hoverIcon }),
-
- React.createElement("div", {
- className: "icon windowaction new",
- title:
- Object.keys(this.state.selection).length > 0 ?
- "Move tabs to new window\nWill move " + maybePluralize(Object.keys(this.state.selection).length, 'selected tab') + " to it" :
- "Open new empty window",
-
- onClick: this.addWindow,
- onMouseEnter: this.hoverIcon }),
-
- React.createElement("div", {
- className: "icon windowaction duplicates" + (this.state.dupTabs ? " enabled" : ""),
- title: "Highlight Duplicates",
- onClick: this.highlightDuplicates,
- onMouseEnter: this.hoverIcon })))))),
-
-
-
-
-
-
- React.createElement("div", { className: "window placeholder" })));
-
-
- } }, { key: "componentDidMount", value: function componentDidMount()
- {
-
- var runUpdate = debounce(this.update, 250);
- runUpdate = runUpdate.bind(this);
-
- browser.tabs.onCreated.addListener(runUpdate);
- browser.tabs.onUpdated.addListener(runUpdate);
- browser.tabs.onMoved.addListener(runUpdate);
- browser.tabs.onRemoved.addListener(runUpdate);
- browser.tabs.onReplaced.addListener(runUpdate);
- browser.tabs.onDetached.addListener(runUpdate);
- browser.tabs.onAttached.addListener(runUpdate);
- browser.tabs.onActivated.addListener(runUpdate);
- browser.windows.onFocusChanged.addListener(runUpdate);
- browser.windows.onCreated.addListener(runUpdate);
- browser.windows.onRemoved.addListener(runUpdate);
-
- browser.storage.onChanged.addListener(this.sessionSync);
-
- this.sessionSync();
-
- this.refs.root.focus();
- this.focusRoot();
- setTimeout(function () {
- var scrollArea = document.getElementsByClassName("window-container")[0];
- var activeWindow = document.getElementsByClassName("activeWindow");
- if (!!activeWindow && activeWindow.length > 0) {
- var activeTab = activeWindow[0].getElementsByClassName("highlighted");
- if (!!activeTab && activeTab.length > 0) {
- if (!!scrollArea && scrollArea.scrollTop > 0) {
- } else {
- activeTab[0].scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" });
- }
- }
- }
- }, 1000);
-
- // box.select();
- // box.focus();
- } }, { key: "sessionSync", value: function () {var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {var values, sessions, key, sess;return regeneratorRuntime.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:_context.next = 2;return (
-
- browser.storage.local.get(null));case 2:values = _context.sent;
- // console.log(values);
- sessions = [];
- for (key in values) {
- sess = values[key];
- if (sess.id && sess.tabs && sess.windowsInfo) {
- sessions.push(values[key]);
- }
- }
- this.state.sessions = sessions;
- this.update();case 7:case "end":return _context.stop();}}}, _callee, this);}));function sessionSync() {return _ref.apply(this, arguments);}return sessionSync;}() }, { key: "focusRoot", value: function focusRoot()
-
- {
- this.state.focusUpdates++;
- setTimeout(
- function () {
- if (document.activeElement == document.body) {
- this.refs.root.focus();
- this.forceUpdate();
- if (this.state.focusUpdates < 5) this.focusRoot();
- }
- }.bind(this),
- 500);
-
- } }, { key: "rateExtension", value: function rateExtension()
- {
- if (navigator.userAgent.search("Firefox") > -1) {
- browser.tabs.create({ url: "https://addons.mozilla.org/en-US/firefox/addon/tab-manager-plus-for-firefox/" });
- } else {
- browser.tabs.create({ url: "https://chrome.google.com/webstore/detail/tab-manager-plus-for-chro/cnkdjjdmfiffagllbiiilooaoofcoeff" });
- }
- this.forceUpdate();
- } }, { key: "donate", value: function donate()
- {
- browser.tabs.create({ url: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=67TZLSEGYQFFW" });
- this.forceUpdate();
- } }, { key: "toggleOptions", value: function toggleOptions()
- {
- this.state.optionsActive = !this.state.optionsActive;
- this.forceUpdate();
- } }, { key: "toggleColors", value: function toggleColors(
- active, windowId) {
- if (!!active) {
- this.state.colorsActive = windowId;
- } else {
- this.state.colorsActive = false;
- }
- console.log("colorsActive", active, windowId, this.state.colorsActive);
- this.forceUpdate();
- } }, { key: "update", value: function () {var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {var windows, tabCount, i, window, j, tab, id;return regeneratorRuntime.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:_context2.next = 2;return (
-
- browser.windows.getAll({ populate: true }));case 2:windows = _context2.sent;
- windows.sort(function (a, b) {
- var windows = [];
- if (!!localStorage["windowAge"]) {
- windows = JSON.parse(localStorage["windowAge"]);
- }
- var aSort = windows.indexOf(a.id);
- var bSort = windows.indexOf(b.id);
- if (a.state == "minimized" && b.state != "minimized") return 1;
- if (b.state == "minimized" && a.state != "minimized") return -1;
- if (aSort < bSort) return -1;
- if (aSort > bSort) return 1;
- return 0;
- });
-
- this.state.lastOpenWindow = windows[0].id;
- this.state.windows = windows;
- this.state.windowsbyid = {};
- this.state.tabsbyid = {};
- tabCount = 0;
- for (i = 0; i < windows.length; i++) {
- window = windows[i];
- this.state.windowsbyid[window.id] = window;
- for (j = 0; j < window.tabs.length; j++) {
- tab = window.tabs[j];
- this.state.tabsbyid[tab.id] = tab;
- tabCount++;
- }
- }
- for (id in this.state.selection) {
- if (!this.state.tabsbyid[id]) {
- delete this.state.selection[id];
- this.state.lastSelect = id;
- }
- }
- this.state.tabCount = tabCount;
- this.setState({
- tabCount: tabCount });
-
- //this.state.searchLen = 0;
- // this.forceUpdate();
- case 13:case "end":return _context2.stop();}}}, _callee2, this);}));function update() {return _ref2.apply(this, arguments);}return update;}() }, { key: "deleteTabs", value: function () {var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {var _this2, tabs, i, t;return regeneratorRuntime.wrap(function _callee3$(_context3) {while (1) {switch (_context3.prev = _context3.next) {case 0:
-
- _this2 = this;
- tabs = Object.keys(this.state.selection).map(function (id) {
- return _this2.state.tabsbyid[id];
- });if (!
- tabs.length) {_context3.next = 12;break;}
- i = 0;case 4:if (!(i < tabs.length)) {_context3.next = 10;break;}_context3.next = 7;return (
- browser.tabs.remove(tabs[i].id));case 7:i++;_context3.next = 4;break;case 10:_context3.next = 18;break;case 12:_context3.next = 14;return (
-
-
- browser.tabs.query({ currentWindow: true, active: true }));case 14:t = _context3.sent;if (!(
- t && t.length > 0)) {_context3.next = 18;break;}_context3.next = 18;return (
- browser.tabs.remove(t[0].id));case 18:
-
-
- this.forceUpdate();case 19:case "end":return _context3.stop();}}}, _callee3, this);}));function deleteTabs() {return _ref3.apply(this, arguments);}return deleteTabs;}() }, { key: "deleteTab", value: function deleteTab(
-
- tabId) {
- browser.tabs.remove(tabId);
- } }, { key: "discardTabs", value: function () {var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {var tabs, i;return regeneratorRuntime.wrap(function _callee4$(_context4) {while (1) {switch (_context4.prev = _context4.next) {case 0:
-
- tabs = Object.keys(this.state.selection).map(function (id) {
- return parseInt(id);
- });
- if (tabs.length) {
- for (i = 0; i < tabs.length; i++) {
- if (!this.state.tabsbyid[tabs[i]].discarded) {
- browser.tabs.discard(tabs[i]).catch(function (e) {
- console.error(e);
- console.log(e.message);
- });
- }
- }
- }
- this.clearSelection();case 3:case "end":return _context4.stop();}}}, _callee4, this);}));function discardTabs() {return _ref4.apply(this, arguments);}return discardTabs;}() }, { key: "discardTab", value: function discardTab(
-
- tabId) {
- browser.tabs.discard(tabId);
- } }, { key: "addWindow", value: function () {var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {var _this3, count, tabs, backgroundPage;return regeneratorRuntime.wrap(function _callee5$(_context5) {while (1) {switch (_context5.prev = _context5.next) {case 0:
-
- _this3 = this;
- count = Object.keys(this.state.selection).length;
- tabs = Object.keys(this.state.selection).map(function (id) {
- return _this3.state.tabsbyid[id];
- });if (!(
-
- count == 0)) {_context5.next = 8;break;}_context5.next = 6;return (
- browser.windows.create({}));case 6:_context5.next = 19;break;case 8:if (!(
- count == 1)) {_context5.next = 15;break;}_context5.next = 11;return (
- browser.runtime.getBackgroundPage());case 11:backgroundPage = _context5.sent;
- if (navigator.userAgent.search("Firefox") > -1) {
- backgroundPage.focusOnTabAndWindowDelayed(tabs[0]);
- } else {
- backgroundPage.focusOnTabAndWindow(tabs[0]);
- }_context5.next = 19;break;case 15:_context5.next = 17;return (
-
- browser.runtime.getBackgroundPage());case 17:backgroundPage = _context5.sent;
- backgroundPage.createWindowWithTabs(tabs);case 19:
-
- if (!!window.inPopup) window.close();case 20:case "end":return _context5.stop();}}}, _callee5, this);}));function addWindow() {return _ref5.apply(this, arguments);}return addWindow;}() }, { key: "pinTabs", value: function () {var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {var _this4, tabs, i, t;return regeneratorRuntime.wrap(function _callee6$(_context6) {while (1) {switch (_context6.prev = _context6.next) {case 0:
-
-
- _this4 = this;
- tabs = Object.keys(this.state.selection).
- map(function (id) {
- return _this4.state.tabsbyid[id];
- }).
- sort(function (a, b) {
- return a.index - b.index;
- });if (!
- tabs.length) {_context6.next = 13;break;}
- if (tabs[0].pinned) tabs.reverse();
- i = 0;case 5:if (!(i < tabs.length)) {_context6.next = 11;break;}_context6.next = 8;return (
- browser.tabs.update(tabs[i].id, { pinned: !tabs[0].pinned }));case 8:i++;_context6.next = 5;break;case 11:_context6.next = 19;break;case 13:_context6.next = 15;return (
-
-
- browser.tabs.query({ currentWindow: true, active: true }));case 15:t = _context6.sent;if (!(
- t && t.length > 0)) {_context6.next = 19;break;}_context6.next = 19;return (
- browser.tabs.update(t[0].id, { pinned: !t[0].pinned }));case 19:case "end":return _context6.stop();}}}, _callee6, this);}));function pinTabs() {return _ref6.apply(this, arguments);}return pinTabs;}() }, { key: "highlightDuplicates", value: function highlightDuplicates(
-
-
-
- e) {
- this.state.selection = {};
- this.state.hiddenTabs = {};
- this.state.searchLen = 0;
- this.state.dupTabs = !this.state.dupTabs;
- this.refs.searchbox.value = "";
- if (!this.state.dupTabs) {
- this.state.hiddenCount = 0;
- this.forceUpdate();
- return;
- }
- var hiddenCount = this.state.hiddenCount || 0;
- var idList = this.state.tabsbyid;
- var dup = [];
- for (var id in idList) {
- var tab = this.state.tabsbyid[id];
- for (var id2 in idList) {
- if (id == id2) continue;
- var tab2 = this.state.tabsbyid[id2];
- if (tab.url == tab2.url) {
- dup.push(id);
- break;
- }
- }
- }
- for (var id in dup) {
- this.state.searchLen++;
- hiddenCount -= this.state.hiddenTabs[dup[id]] || 0;
- this.state.selection[dup[id]] = true;
- delete this.state.hiddenTabs[dup[id]];
- this.state.lastSelect = dup[id];
- }
- for (var id in idList) {
- var tab = this.state.tabsbyid[id];
- if (dup.indexOf(id) === -1) {
- hiddenCount += 1 - (this.state.hiddenTabs[id] || 0);
- this.state.hiddenTabs[id] = true;
- delete this.state.selection[id];
- this.state.lastSelect = id;
- }
- }
- if (dup.length == 0) {
- this.setState({
- topText: "No duplicates found",
- bottomText: " " });
-
- } else {
- this.setState({
- topText: "Highlighted " + dup.length + " duplicate tabs",
- bottomText: "Press enter to move them to a new window" });
-
- }
- this.state.hiddenCount = hiddenCount;
- this.forceUpdate();
- } }, { key: "search", value: function search(
- e) {
- var hiddenCount = this.state.hiddenCount || 0;
- var searchQuery = e.target.value || "";
- var searchLen = searchQuery.length;
-
- var searchType = "normal";
- var searchTerms = [];
- if (searchQuery.indexOf(" ") === -1) {
- searchType = "normal";
- } else if (searchQuery.indexOf(" OR ") > -1) {
- searchTerms = searchQuery.split(" OR ");
- searchType = "OR";
- } else if (searchQuery.indexOf(" ") > -1) {
- searchTerms = searchQuery.split(" ");
- searchType = "AND";
- }
- if (searchType != "normal") {
- searchTerms = searchTerms.filter(function (entry) {return entry.trim() != '';});
- }
-
- if (!searchLen) {
- this.state.selection = {};
- this.state.hiddenTabs = {};
- hiddenCount = 0;
- } else {
- var idList;
- var lastSearchLen = this.state.searchLen;
- idList = this.state.tabsbyid;
- if (searchType == "normal") {
- if (!lastSearchLen) {
- idList = this.state.tabsbyid;
- } else if (lastSearchLen > searchLen) {
- idList = this.state.hiddenTabs;
- } else if (lastSearchLen < searchLen) {
- idList = this.state.selection;
- }
- }
- for (var id in idList) {
- var tab = this.state.tabsbyid[id];
- var tabSearchTerm = (tab.title + tab.url).toLowerCase();
- var match = false;
- if (searchType == "normal") {
- match = tabSearchTerm.indexOf(e.target.value.toLowerCase()) >= 0;
- } else if (searchType == "OR") {var _iteratorNormalCompletion = true;var _didIteratorError = false;var _iteratorError = undefined;try {
- for (var _iterator = searchTerms[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {var searchOR = _step.value;
- searchOR = searchOR.trim().toLowerCase();
- if (tabSearchTerm.indexOf(searchOR) >= 0) {
- match = true;
- break;
- }
- }} catch (err) {_didIteratorError = true;_iteratorError = err;} finally {try {if (!_iteratorNormalCompletion && _iterator.return) {_iterator.return();}} finally {if (_didIteratorError) {throw _iteratorError;}}}
- } else if (searchType == "AND") {
- var andMatch = true;var _iteratorNormalCompletion2 = true;var _didIteratorError2 = false;var _iteratorError2 = undefined;try {
- for (var _iterator2 = searchTerms[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {var searchAND = _step2.value;
- searchAND = searchAND.trim().toLowerCase();
- if (tabSearchTerm.indexOf(searchAND) >= 0) {
-
- } else {
- andMatch = false;
- break;
- }
- }} catch (err) {_didIteratorError2 = true;_iteratorError2 = err;} finally {try {if (!_iteratorNormalCompletion2 && _iterator2.return) {_iterator2.return();}} finally {if (_didIteratorError2) {throw _iteratorError2;}}}
- match = andMatch;
- }
- if (match) {
- hiddenCount -= this.state.hiddenTabs[id] || 0;
- this.state.selection[id] = true;
- delete this.state.hiddenTabs[id];
- this.state.lastSelect = id;
- } else {
- hiddenCount += 1 - (this.state.hiddenTabs[id] || 0);
- this.state.hiddenTabs[id] = true;
- delete this.state.selection[id];
- this.state.lastSelect = id;
- }
- }
- }
- this.state.hiddenCount = hiddenCount;
- this.state.searchLen = searchLen;
- var matches = Object.keys(this.state.selection).length;
- var matchtext = "";
- if (matches == 0 && searchLen > 0) {
- this.setState({
- topText: "No matches for '" + e.target.value + "'",
- bottomText: "" });
-
- } else if (matches == 0) {
- this.setState({
- topText: "",
- bottomText: "" });
-
- } else if (matches > 1) {
- this.setState({
- topText: Object.keys(this.state.selection).length + " matches for '" + e.target.value + "'",
- bottomText: "Press enter to move them to a new window" });
-
- } else if (matches == 1) {
- this.setState({
- topText: Object.keys(this.state.selection).length + " match for '" + e.target.value + "'",
- bottomText: "Press enter to switch to the tab" });
-
- }
- this.forceUpdate();
- } }, { key: "clearSelection", value: function clearSelection()
- {
- this.state.selection = {};
- this.setState({
- lastSelect: false });
-
- } }, { key: "checkKey", value: function checkKey(
- e) {
- // enter
- if (e.keyCode == 13) this.addWindow();
- // escape key
- if (e.keyCode == 27) {
- if (this.state.searchLen > 0 || Object.keys(this.state.selection).length > 0) {
- // stop popup from closing if we have search text or selection active
- e.nativeEvent.preventDefault();
- e.nativeEvent.stopPropagation();
- }
- this.state.hiddenTabs = {};
- this.state.searchLen = 0;
- this.refs.searchbox.value = "";
- this.clearSelection();
- }
- // any typed keys
- if (
- e.keyCode >= 48 && e.keyCode <= 57 ||
- e.keyCode >= 65 && e.keyCode <= 90 ||
- e.keyCode >= 186 && e.keyCode <= 192 ||
- e.keyCode >= 219 && e.keyCode <= 22 ||
- e.keyCode == 8 ||
- e.keyCode == 46 ||
- e.keyCode == 32)
- {
- if (document.activeElement != this.refs.searchbox) {
- if (document.activeElement.type != "text" && document.activeElement.type != "input") {
- this.refs.searchbox.focus();
- }
- }
- }
- // arrow keys
- /*
- left arrow 37
- up arrow 38
- right arrow 39
- down arrow 40
- */
- if (e.keyCode >= 37 && e.keyCode <= 40) {
- if (document.activeElement != this.refs.windowcontainer && document.activeElement != this.refs.searchbox) {
- this.refs.windowcontainer.focus();
- }
-
- if (document.activeElement != this.refs.searchbox || !this.refs.searchbox.value) {
- var goLeft = e.keyCode == 37;
- var goRight = e.keyCode == 39;
- var goUp = e.keyCode == 38;
- var goDown = e.keyCode == 40;
- if (this.state.layout == "vertical") {
- goLeft = e.keyCode == 38;
- goRight = e.keyCode == 40;
- goUp = e.keyCode == 37;
- goDown = e.keyCode == 39;
- }
- if (goLeft || goRight || goUp || goDown) {
- e.nativeEvent.preventDefault();
- e.nativeEvent.stopPropagation();
- }
- var altKey = e.nativeEvent.metaKey || e.nativeEvent.altKey || e.nativeEvent.shiftKey || e.nativeEvent.ctrlKey;
- if (goLeft || goRight) {
- var selectedTabs = Object.keys(this.state.selection);
- if (!altKey && selectedTabs.length > 1) {
- } else {
- var found = false;
- var selectedNext = false;
- var selectedTab = false;
- var first = false;
- var prev = false;
- var last = false;
- if (selectedTabs.length == 1) {
- selectedTab = selectedTabs[0];
- // console.log("one tab", selectedTab);
- } else if (selectedTabs.length > 1) {
- if (this.state.lastSelect) {
- selectedTab = this.state.lastSelect;
- // console.log("more tabs, last", selectedTab);
- } else {
- selectedTab = selectedTabs[0];
- // console.log("more tabs, first", selectedTab);
- }
- } else if (selectedTabs.length == 0 && this.state.lastSelect) {
- selectedTab = this.state.lastSelect;
- // console.log("no tabs, last", selectedTab);
- }
- if (this.state.lastDirection) {
- if (goRight && this.state.lastDirection == "goRight") {
- } else if (goLeft && this.state.lastDirection == "goLeft") {
- } else if (selectedTabs.length > 1) {
- // console.log("turned back, last", this.state.lastSelect, selectedTab);
- this.select(this.state.lastSelect);
- this.state.lastDirection = false;
- found = true;
- } else {
- this.state.lastDirection = false;
- }
- }
- if (!this.state.lastDirection) {
- if (goRight) this.state.lastDirection = "goRight";
- if (goLeft) this.state.lastDirection = "goLeft";
- }var _iteratorNormalCompletion3 = true;var _didIteratorError3 = false;var _iteratorError3 = undefined;try {
- for (var _iterator3 = this.state.windows[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {var _w = _step3.value;
- if (found) break;
- if (_w.state != "minimized") {var _iteratorNormalCompletion5 = true;var _didIteratorError5 = false;var _iteratorError5 = undefined;try {
- for (var _iterator5 = _w.tabs[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {var _t = _step5.value;
- last = _t.id;
- if (!first) first = _t.id;
- if (!selectedTab) {
- if (!altKey) this.state.selection = {};
- this.select(_t.id);
- found = true;
- break;
- } else if (selectedTab == _t.id) {
- // console.log("select next one", selectedNext);
- if (goRight) {
- selectedNext = true;
- } else if (prev) {
- if (!altKey) this.state.selection = {};
- this.select(prev);
- found = true;
- break;
- }
- } else if (selectedNext) {
- if (!altKey) this.state.selection = {};
- this.select(_t.id);
- found = true;
- break;
- }
- prev = _t.id;
- // console.log(_t, _t.id == selectedTab);
- }} catch (err) {_didIteratorError5 = true;_iteratorError5 = err;} finally {try {if (!_iteratorNormalCompletion5 && _iterator5.return) {_iterator5.return();}} finally {if (_didIteratorError5) {throw _iteratorError5;}}}
- }
- }} catch (err) {_didIteratorError3 = true;_iteratorError3 = err;} finally {try {if (!_iteratorNormalCompletion3 && _iterator3.return) {_iterator3.return();}} finally {if (_didIteratorError3) {throw _iteratorError3;}}}var _iteratorNormalCompletion4 = true;var _didIteratorError4 = false;var _iteratorError4 = undefined;try {
- for (var _iterator4 = this.state.windows[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {var _w = _step4.value;
- if (found) break;
- if (_w.state == "minimized") {var _iteratorNormalCompletion6 = true;var _didIteratorError6 = false;var _iteratorError6 = undefined;try {
- for (var _iterator6 = _w.tabs[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {var _t = _step6.value;
- last = _t.id;
- if (!first) first = _t.id;
- if (!selectedTab) {
- if (!altKey) this.state.selection = {};
- this.select(_t.id);
- found = true;
- break;
- } else if (selectedTab == _t.id) {
- if (goRight) {
- selectedNext = true;
- } else if (prev) {
- if (!altKey) this.state.selection = {};
- this.select(prev);
- found = true;
- break;
- }
- } else if (selectedNext) {
- if (!altKey) this.state.selection = {};
- this.select(_t.id);
- found = true;
- break;
- }
- prev = _t.id;
- // console.log(_t, _t.id == selectedTab);
- }} catch (err) {_didIteratorError6 = true;_iteratorError6 = err;} finally {try {if (!_iteratorNormalCompletion6 && _iterator6.return) {_iterator6.return();}} finally {if (_didIteratorError6) {throw _iteratorError6;}}}
- }
- }} catch (err) {_didIteratorError4 = true;_iteratorError4 = err;} finally {try {if (!_iteratorNormalCompletion4 && _iterator4.return) {_iterator4.return();}} finally {if (_didIteratorError4) {throw _iteratorError4;}}}
- if (!found && goRight && first) {
- if (!altKey) this.state.selection = {};
- this.select(first);
- found = true;
- }
- if (!found && goLeft && last) {
- if (!altKey) this.state.selection = {};
- this.select(last);
- found = true;
- }
- }
- }
- if (goUp || goDown) {
- var selectedTabs = Object.keys(this.state.selection);
- if (selectedTabs.length > 1) {
- } else {
- var found = false;
- var selectedNext = false;
- var selectedTab = -1;
- var first = false;
- var prev = false;
- var last = false;
- var tabPosition = -1;
- var i = -1;
- if (selectedTabs.length == 1) {
- selectedTab = selectedTabs[0];
- // console.log(selectedTab);
- }var _iteratorNormalCompletion7 = true;var _didIteratorError7 = false;var _iteratorError7 = undefined;try {
- for (var _iterator7 = this.state.windows[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {var _w = _step7.value;
- i = 0;
- if (found) break;
- if (_w.state != "minimized") {
- if (!first) first = _w.id;var _iteratorNormalCompletion9 = true;var _didIteratorError9 = false;var _iteratorError9 = undefined;try {
- for (var _iterator9 = _w.tabs[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {var _t = _step9.value;
- i++;
- last = _w.id;
- if (!selectedTab) {
- this.selectWindowTab(_w.id, tabPosition);
- found = true;
- break;
- } else if (selectedTab == _t.id) {
- tabPosition = i;
- // console.log("found tab", _w.id, _t.id, selectedTab, i);
- if (goDown) {
- // console.log("select next window ", selectedNext, tabPosition);
- selectedNext = true;
- break;
- } else if (prev) {
- // console.log("select prev window ", prev, tabPosition);
- this.selectWindowTab(prev, tabPosition);
- found = true;
- break;
- }
- } else if (selectedNext) {
- // console.log("selecting next window ", _w.id, tabPosition);
- this.selectWindowTab(_w.id, tabPosition);
- found = true;
- break;
- }
-
- // console.log(_t, _t.id == selectedTab);
- }} catch (err) {_didIteratorError9 = true;_iteratorError9 = err;} finally {try {if (!_iteratorNormalCompletion9 && _iterator9.return) {_iterator9.return();}} finally {if (_didIteratorError9) {throw _iteratorError9;}}}
- prev = _w.id;
- }
- }} catch (err) {_didIteratorError7 = true;_iteratorError7 = err;} finally {try {if (!_iteratorNormalCompletion7 && _iterator7.return) {_iterator7.return();}} finally {if (_didIteratorError7) {throw _iteratorError7;}}}var _iteratorNormalCompletion8 = true;var _didIteratorError8 = false;var _iteratorError8 = undefined;try {
- for (var _iterator8 = this.state.windows[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {var _w = _step8.value;
- i = 0;
- if (found) break;
- if (_w.state == "minimized") {
- if (!first) first = _w.id;var _iteratorNormalCompletion10 = true;var _didIteratorError10 = false;var _iteratorError10 = undefined;try {
- for (var _iterator10 = _w.tabs[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {var _t = _step10.value;
- i++;
- last = _w.id;
- if (!selectedTab) {
- this.selectWindowTab(_w.id, tabPosition);
- found = true;
- break;
- } else if (selectedTab == _t.id) {
- tabPosition = i;
- // console.log("found tab", _w.id, _t.id, selectedTab, i);
- if (goDown) {
- // console.log("select next window ", selectedNext, tabPosition);
- selectedNext = true;
- break;
- } else if (prev) {
- // console.log("select prev window ", prev, tabPosition);
- this.selectWindowTab(prev, tabPosition);
- found = true;
- break;
- }
- } else if (selectedNext) {
- // console.log("selecting next window ", _w.id, tabPosition);
- this.selectWindowTab(_w.id, tabPosition);
- found = true;
- break;
- }
- // console.log(_t, _t.id == selectedTab);
- }} catch (err) {_didIteratorError10 = true;_iteratorError10 = err;} finally {try {if (!_iteratorNormalCompletion10 && _iterator10.return) {_iterator10.return();}} finally {if (_didIteratorError10) {throw _iteratorError10;}}}
- prev = _w.id;
- }
- }
- // console.log(found, goDown, first);
- } catch (err) {_didIteratorError8 = true;_iteratorError8 = err;} finally {try {if (!_iteratorNormalCompletion8 && _iterator8.return) {_iterator8.return();}} finally {if (_didIteratorError8) {throw _iteratorError8;}}}if (!found && goDown && first) {
- // console.log("go first", first);
- this.state.selection = {};
- this.selectWindowTab(first, tabPosition);
- found = true;
- }
- // console.log(found, goUp, last);
- if (!found && goUp && last) {
- // console.log("go last", last);
- this.state.selection = {};
- this.selectWindowTab(last, tabPosition);
- found = true;
- }
- }
- }
- }
- }
- // page up / page down
- if (e.keyCode == 33 || e.keyCode == 34) {
- if (document.activeElement != this.refs.windowcontainer) {
- this.refs.windowcontainer.focus();
- }
- }
- } }, { key: "selectWindowTab", value: function selectWindowTab(
- windowId, tabPosition) {
- if (!tabPosition || tabPosition < 1) tabPosition = 1;var _iteratorNormalCompletion11 = true;var _didIteratorError11 = false;var _iteratorError11 = undefined;try {
- for (var _iterator11 = this.state.windows[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {var _w = _step11.value;
- if (_w.id != windowId) continue;
- var i = 0;var _iteratorNormalCompletion12 = true;var _didIteratorError12 = false;var _iteratorError12 = undefined;try {
- for (var _iterator12 = _w.tabs[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {var _t = _step12.value;
- i++;
- if (_w.tabs.length >= tabPosition && tabPosition == i || _w.tabs.length < tabPosition && _w.tabs.length == i) {
- this.state.selection = {};
- this.select(_t.id);
- }
- }} catch (err) {_didIteratorError12 = true;_iteratorError12 = err;} finally {try {if (!_iteratorNormalCompletion12 && _iterator12.return) {_iterator12.return();}} finally {if (_didIteratorError12) {throw _iteratorError12;}}}
- }} catch (err) {_didIteratorError11 = true;_iteratorError11 = err;} finally {try {if (!_iteratorNormalCompletion11 && _iterator11.return) {_iterator11.return();}} finally {if (_didIteratorError11) {throw _iteratorError11;}}}
- } }, { key: "scrollTo", value: function scrollTo(
- what, id) {
- var els = document.getElementById(what + "-" + id);
- if (!!els) {
- if (!this.elVisible(els)) {
- els.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" });
- }
- }
- } }, { key: "changelayout", value: function changelayout()
- {
- if (this.state.layout == "blocks") {
- localStorage["layout"] = this.state.layout = "blocks-big";
- } else if (this.state.layout == "blocks-big") {
- localStorage["layout"] = this.state.layout = "horizontal";
- } else if (this.state.layout == "horizontal") {
- localStorage["layout"] = this.state.layout = "vertical";
- } else {
- localStorage["layout"] = this.state.layout = "blocks";
- }
- this.setState({ topText: "Switched to " + this.readablelayout(this.state.layout) + " view" });
- this.setState({ bottomText: " " });
- this.forceUpdate();
- } }, { key: "nextlayout", value: function nextlayout()
- {
- if (this.state.layout == "blocks") {
- return "blocks-big";
- } else if (this.state.layout == "blocks-big") {
- return "horizontal";
- } else if (this.state.layout == "horizontal") {
- return "vertical";
- } else {
- return "blocks";
- }
- } }, { key: "readablelayout", value: function readablelayout(
- layout) {
- if (layout == "blocks") {
- return "Block";
- } else if (layout == "blocks-big") {
- return "Big Block";
- } else if (layout == "horizontal") {
- return "Horizontal";
- } else {
- return "Vertical";
- }
- } }, { key: "select", value: function select(
- id) {
- if (this.state.selection[id]) {
- delete this.state.selection[id];
- this.setState({
- lastSelect: id });
-
- } else {
- this.state.selection[id] = true;
- this.setState({
- lastSelect: id });
-
- }
- this.scrollTo('tab', id);
- var tab = this.state.tabsbyid[id];
- if (this.refs['window' + tab.windowId] && this.refs['window' + tab.windowId].refs['tab' + id]) {
- this.refs['window' + tab.windowId].refs['tab' + id].resolveFavIconUrl();
- }
-
- var selected = Object.keys(this.state.selection).length;
- if (selected == 0) {
- this.setState({
- topText: "No tabs selected",
- bottomText: " " });
-
- } else if (selected == 1) {
- this.setState({
- topText: "Selected " + selected + " tab",
- bottomText: "Press enter to switch to it" });
-
- } else {
- this.setState({
- topText: "Selected " + selected + " tabs",
- bottomText: "Press enter to move them to a new window" });
-
- }
- } }, { key: "selectTo", value: function selectTo(
- id, tabs) {
- var activate = false;
- var lastSelect = this.state.lastSelect;
- if (id == lastSelect) {
- this.select(id);
- return;
- }
- if (!!lastSelect) {
- if (this.state.selection[lastSelect]) {
- activate = true;
- }
- } else {
- if (this.state.selection[id]) {
- activate = false;
- } else {
- activate = true;
- }
- }
-
- var rangeIndex1;
- var rangeIndex2;
- var selectedTabs = [];
- for (var i = 0; i < tabs.length; i++) {
- if (tabs[i].id == id) {
- rangeIndex1 = i;
- }
- if (!!lastSelect && tabs[i].id == lastSelect) {
- rangeIndex2 = i;
- }
- }
- if (!!lastSelect && !rangeIndex2) {
- this.select(id);
- return;
- }
- if (!rangeIndex2) {
- var neighbours = [];
- for (var i = 0; i < tabs.length; i++) {
- var tabId = tabs[i].id;
- if (tabId != id) {
- if (this.state.selection[tabId]) {
- neighbours.push(tabId);
- }
- }
- }
-
- if (activate) {
- // find closest selected item that's not connected
- var leftSibling = 0;
- var rightSibling = tabs.length - 1;
- for (var i = 0; i < rangeIndex1; i++) {
- if (neighbours.indexOf(i) > -1) {
- leftSibling = i;
- }
- }
- for (var i = tabs.length - 1; i > rangeIndex1; i--) {
- if (neighbours.indexOf(i) > -1) {
- rightSibling = i;
- }
- }
- var diff1 = rangeIndex1 - leftSibling;
- var diff2 = rightSibling - rangeIndex1;
- if (diff1 > diff2) {
- rangeIndex2 = rightSibling;
- } else {
- rangeIndex2 = leftSibling;
- }
- } else {
- // find furthest selected item that's connected
- var leftSibling = rangeIndex1;
- var rightSibling = rangeIndex1;
- for (var i = rangeIndex1; i > 0; i--) {
- if (neighbours.indexOf(i) > -1) {
- leftSibling = i;
- }
- }
- for (var i = rangeIndex1; i < tabs.length; i++) {
- if (neighbours.indexOf(i) > -1) {
- rightSibling = i;
- }
- }
- var diff1 = rangeIndex1 - leftSibling;
- var diff2 = rightSibling - rangeIndex1;
- if (diff1 > diff2) {
- rangeIndex2 = leftSibling;
- } else {
- rangeIndex2 = rightSibling;
- }
- }
- }
-
- this.setState({
- lastSelect: tabs[rangeIndex2].id });
-
- if (rangeIndex2 < rangeIndex1) {
- var r1 = rangeIndex2;
- var r2 = rangeIndex1;
- rangeIndex1 = r1;
- rangeIndex2 = r2;
- }
-
- for (var i = 0; i < tabs.length; i++) {
- if (i >= rangeIndex1 && i <= rangeIndex2) {
- var tabId = tabs[i].id;
- if (activate) {
- this.state.selection[tabId] = true;
- } else {
- delete this.state.selection[tabId];
- }
- }
- }
-
- this.scrollTo('tab', this.state.lastSelect);
-
- var selected = Object.keys(this.state.selection).length;
- if (selected == 0) {
- this.setState({
- topText: "No tabs selected",
- bottomText: " " });
-
- } else if (selected == 1) {
- this.setState({
- topText: "Selected " + selected + " tab",
- bottomText: "Press enter to switch to it" });
-
- } else {
- this.setState({
- topText: "Selected " + selected + " tabs",
- bottomText: "Press enter to move them to a new window" });
-
- }
- this.forceUpdate();
- } }, { key: "drag", value: function drag(
- e, id) {
- if (!this.state.selection[id]) {
- this.state.selection = {};
- this.state.selection[id] = true;
- this.state.lastSelect = id;
- }
- this.forceUpdate();
- } }, { key: "drop", value: function () {var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(
- id, before) {var _this5, tab, tabs, index, i, t;return regeneratorRuntime.wrap(function _callee7$(_context7) {while (1) {switch (_context7.prev = _context7.next) {case 0:
- _this5 = this;
- tab = this.state.tabsbyid[id];
- tabs = Object.keys(this.state.selection).map(function (id) {
- return _this5.state.tabsbyid[id];
- });
- index = tab.index + (before ? 0 : 1);
-
- i = 0;case 5:if (!(i < tabs.length)) {_context7.next = 14;break;}
- t = tabs[i];_context7.next = 9;return (
- browser.tabs.move(t.id, { windowId: tab.windowId, index: index }));case 9:_context7.next = 11;return (
- browser.tabs.update(t.id, { pinned: t.pinned }));case 11:i++;_context7.next = 5;break;case 14:
-
- this.setState({
- selection: {} });
-
- this.update();case 16:case "end":return _context7.stop();}}}, _callee7, this);}));function drop(_x, _x2) {return _ref7.apply(this, arguments);}return drop;}() }, { key: "dropWindow", value: function () {var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(
-
- windowId) {var _this6, tabs, i, t;return regeneratorRuntime.wrap(function _callee8$(_context8) {while (1) {switch (_context8.prev = _context8.next) {case 0:
- _this6 = this;
- tabs = Object.keys(this.state.selection).map(function (id) {
- return _this6.state.tabsbyid[id];
- });
- i = 0;case 3:if (!(i < tabs.length)) {_context8.next = 12;break;}
- t = tabs[i];_context8.next = 7;return (
- browser.tabs.move(t.id, { windowId: windowId, index: -1 }));case 7:_context8.next = 9;return (
- browser.tabs.update(t.id, { pinned: t.pinned }));case 9:i++;_context8.next = 3;break;case 12:
-
- this.setState({
- selection: {} });case 13:case "end":return _context8.stop();}}}, _callee8, this);}));function dropWindow(_x3) {return _ref8.apply(this, arguments);}return dropWindow;}() }, { key: "changeTabLimit", value: function changeTabLimit(
-
-
- e) {
- this.state.tabLimit = e.target.value;
- localStorage["tabLimit"] = JSON.stringify(this.state.tabLimit);
- this.tabLimitText();
- this.forceUpdate();
- } }, { key: "tabLimitText", value: function tabLimitText()
- {
- this.setState({
- bottomText: "Limit the number of tabs per window. Will move new tabs into a new window instead. 0 to turn off" });
-
- } }, { key: "changeTabWidth", value: function changeTabWidth(
- e) {
- this.state.tabWidth = e.target.value;
- localStorage["tabWidth"] = JSON.stringify(this.state.tabWidth);
- document.body.style.width = this.state.tabWidth + "px";
- this.tabWidthText();
- this.forceUpdate();
- } }, { key: "tabWidthText", value: function tabWidthText()
- {
- this.setState({
- bottomText: "Change the width of this window. 800 by default." });
-
- } }, { key: "changeTabHeight", value: function changeTabHeight(
- e) {
- this.state.tabHeight = e.target.value;
- localStorage["tabHeight"] = JSON.stringify(this.state.tabHeight);
- document.body.style.height = this.state.tabHeight + "px";
- this.tabHeightText();
- this.forceUpdate();
- } }, { key: "tabHeightText", value: function tabHeightText()
- {
- this.setState({
- bottomText: "Change the height of this window. 600 by default." });
-
- } }, { key: "toggleAnimations", value: function toggleAnimations()
- {
- this.state.animations = !this.state.animations;
- localStorage["animations"] = this.state.animations ? "1" : "0";
- this.animationsText();
- this.forceUpdate();
- } }, { key: "animationsText", value: function animationsText()
- {
- this.setState({
- bottomText: "Enables/disables animations. Default : on" });
-
- } }, { key: "toggleWindowTitles", value: function toggleWindowTitles()
- {
- this.state.windowTitles = !this.state.windowTitles;
- localStorage["windowTitles"] = this.state.windowTitles ? "1" : "0";
- this.windowTitlesText();
- this.forceUpdate();
- } }, { key: "windowTitlesText", value: function windowTitlesText()
- {
- this.setState({
- bottomText: "Enables/disables window titles. Default : on" });
-
- } }, { key: "toggleCompact", value: function toggleCompact()
- {
- this.state.compact = !this.state.compact;
- localStorage["compact"] = this.state.compact ? "1" : "0";
- this.compactText();
- this.forceUpdate();
- } }, { key: "compactText", value: function compactText()
- {
- this.setState({
- bottomText: "Compact mode is a more compressed layout. Default : off" });
-
- } }, { key: "toggleDark", value: function toggleDark()
- {
- this.state.dark = !this.state.dark;
- localStorage["dark"] = this.state.dark ? "1" : "0";
- this.darkText();
- if (this.state.dark) {
- document.body.className = "dark";
- } else {
- document.body.className = "";
- }
- this.forceUpdate();
- } }, { key: "darkText", value: function darkText()
- {
- this.setState({
- bottomText: "Dark mode inverts the layout - better on the eyes. Default : off" });
-
- } }, { key: "toggleTabActions", value: function toggleTabActions()
- {
- this.state.tabactions = !this.state.tabactions;
- localStorage["tabactions"] = this.state.tabactions ? "1" : "0";
- this.tabActionsText();
- this.forceUpdate();
- } }, { key: "tabActionsText", value: function tabActionsText()
- {
- this.setState({
- bottomText: "Adds 'Open a new tab' and 'Close this window' option to each window. Default : on" });
-
- } }, { key: "toggleBadge", value: function () {var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {var backgroundPage;return regeneratorRuntime.wrap(function _callee9$(_context9) {while (1) {switch (_context9.prev = _context9.next) {case 0:
-
- this.state.badge = !this.state.badge;
- localStorage["badge"] = this.state.badge ? "1" : "0";
- this.badgeText();_context9.next = 5;return (
- browser.runtime.getBackgroundPage());case 5:backgroundPage = _context9.sent;
- backgroundPage.updateTabCount();
- this.forceUpdate();case 8:case "end":return _context9.stop();}}}, _callee9, this);}));function toggleBadge() {return _ref9.apply(this, arguments);}return toggleBadge;}() }, { key: "badgeText", value: function badgeText()
-
- {
- this.setState({
- bottomText: "Shows the number of open tabs on the Tab Manager icon. Default : on" });
-
- } }, { key: "toggleOpenInOwnTab", value: function toggleOpenInOwnTab()
- {
- this.state.openInOwnTab = !this.state.openInOwnTab;
- localStorage["openInOwnTab"] = this.state.openInOwnTab ? "1" : "0";
- this.openInOwnTabText();
- browser.runtime.sendMessage({ command: "reload_popup_controls" });
- this.forceUpdate();
- } }, { key: "openInOwnTabText", value: function openInOwnTabText()
- {
- this.setState({
- bottomText: "Open the Tab Manager by default in own tab, or as a popup?" });
-
- } }, { key: "toggleSessions", value: function toggleSessions()
- {
- this.state.sessionsFeature = !this.state.sessionsFeature;
- localStorage["sessionsFeature"] = this.state.sessionsFeature ? "1" : "0";
- this.sessionsText();
- this.forceUpdate();
- } }, { key: "sessionsText", value: function sessionsText()
- {
- this.setState({
- bottomText: "Allows you to save/restore windows into sessions. ( Tab History will be lost ) Default : off" });
-
- } }, { key: "exportSessions", value: function exportSessions()
- {
- if (this.state.sessions.length == 0) {
- window.alert("You have currently no windows saved for later. There is nothing to export.");
- return;
- }
- var exportName = "tab-manager-plus-backup";
- var today = new Date();
- var y = today.getFullYear();
- // JavaScript months are 0-based.
- var m = ("0" + (today.getMonth() + 1)).slice(-2);
- var d = ("0" + today.getDate()).slice(-2);
- var h = ("0" + today.getHours()).slice(-2);
- var mi = ("0" + today.getMinutes()).slice(-2);
- var s = ("0" + today.getSeconds()).slice(-2);
- exportName += "-" + y + m + d + "-" + h + mi + "-" + s;
- var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(this.state.sessions, null, 2));
- var downloadAnchorNode = document.createElement("a");
- downloadAnchorNode.setAttribute("href", dataStr);
- downloadAnchorNode.setAttribute("download", exportName + ".json");
- document.body.appendChild(downloadAnchorNode); // required for firefox
- downloadAnchorNode.click();
- downloadAnchorNode.remove();
- this.exportSessionsText();
- this.forceUpdate();
- } }, { key: "exportSessionsText", value: function exportSessionsText()
- {
- this.setState({
- bottomText: "Allows you to export your saved windows to an external backup" });
-
- } }, { key: "importSessions", value: function importSessions(
- evt) {var _this8 = this;
- if (navigator.userAgent.search("Firefox") > -1) {
- if (window.inPopup) {
- window.alert("Due to a Firefox bug session import does not work in the popup. Please use the options screen or open Tab Manager Plus in its' own tab");
- return;
- }
- }
- try {
- var inputField = evt.target; // #session_import
- var files = evt.target.files;
- if (!files.length) {
- alert("No file selected!");
- this.setState({ bottomText: "Error: Could not read the backup file!" });
- return;
- }
- var file = files[0];
- var reader = new FileReader();
- var self = this;
- reader.onload = function () {var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(event) {var backupFile, success, i, newSession, obj, value;return regeneratorRuntime.wrap(function _callee10$(_context10) {while (1) {switch (_context10.prev = _context10.next) {case 0:
-
-
- try {
- backupFile = JSON.parse(event.target.result);
- } catch (err) {
- console.error(err);
- window.alert(err);
- _this8.setState({ bottomText: "Error: Could not read the backup file!" });
- } //console.log('FILE CONTENT', event.target.result);
- if (!(!!backupFile && backupFile.length > 0)) {_context10.next = 18;break;}
- success = backupFile.length;
- i = 0;case 4:if (!(i < backupFile.length)) {_context10.next = 15;break;}
- newSession = backupFile[i];if (!(
- newSession.windowsInfo && newSession.tabs && newSession.id)) {_context10.next = 12;break;}
- obj = {};
- obj[newSession.id] = newSession;
- //this.state.sessions.push(obj);
- _context10.next = 11;return browser.storage.local.set(obj).catch(function (err) {
- console.log(err);
- console.error(err.message);
- success--;
- });case 11:value = _context10.sent;case 12:i++;_context10.next = 4;break;case 15:
-
-
-
- _this8.setState({ bottomText: success + " windows successfully restored!" });_context10.next = 19;break;case 18:
-
- _this8.setState({ bottomText: "Error: Could not restore any windows from the backup file!" });case 19:
-
- inputField.value = "";
- _this8.sessionSync();case 21:case "end":return _context10.stop();}}}, _callee10, _this8);}));return function (_x4) {return _ref10.apply(this, arguments);};}();
-
- reader.readAsText(file);
- } catch (err) {
- console.error(err);
- window.alert(err);
- }
- this.importSessionsText();
- this.forceUpdate();
- } }, { key: "importSessionsText", value: function importSessionsText()
- {
- this.setState({
- bottomText: "Allows you to restore your saved windows from an external backup" });
-
- } }, { key: "toggleHide", value: function () {var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {var granted;return regeneratorRuntime.wrap(function _callee11$(_context11) {while (1) {switch (_context11.prev = _context11.next) {case 0:_context11.next = 2;return (
-
- browser.permissions.request({ permissions: ["system.display"] }));case 2:granted = _context11.sent;
- if (granted) {
- this.state.hideWindows = !this.state.hideWindows;
- } else {
- this.state.hideWindows = false;
- }
- localStorage["hideWindows"] = this.state.hideWindows ? "1" : "0";
- this.hideText();
- this.forceUpdate();case 7:case "end":return _context11.stop();}}}, _callee11, this);}));function toggleHide() {return _ref11.apply(this, arguments);}return toggleHide;}() }, { key: "hideText", value: function hideText()
-
- {
- this.setState({
- bottomText: "Automatically minimizes inactive chrome windows. Default : off" });
-
- } }, { key: "toggleFilterMismatchedTabs", value: function toggleFilterMismatchedTabs()
- {
- this.state.filterTabs = !this.state.filterTabs;
- localStorage["filter-tabs"] = this.state.filterTabs ? "1" : "0";
- this.forceUpdate();
- } }, { key: "getTip", value: function getTip()
- {
- var tips = [
- "You can right click on a tab to select it",
- "Press enter to move all selected tabs to a new window",
- "Middle click to close a tab",
- "Tab Manager Plus loves saving time",
- "To see incognito tabs, enable incognito access in the extension settings",
- "You can drag and drop tabs to other windows",
- "You can type to search right away",
- "You can search for different tabs : google OR yahoo"];
-
-
- return "Tip: " + tips[Math.floor(Math.random() * tips.length)];
- } }, { key: "toBoolean", value: function toBoolean(
- str) {
- if (typeof str === "undefined" || str === null) {
- return false;
- } else if (typeof str === "string") {
- switch (str.toLowerCase()) {
- case "false":
- case "no":
- case "0":
- case "":
- return false;
- default:
- return true;}
-
- } else if (typeof str === "number") {
- return str !== 0;
- } else {
- return true;
- }
- } }, { key: "localStorageAvailable", value: function localStorageAvailable()
- {
- var test = "test";
- try {
- localStorage.setItem(test, test);
- localStorage.removeItem(test);
- return true;
- } catch (e) {
- return false;
- }
- } }, { key: "isInViewport", value: function isInViewport(
- element, ofElement) {
- var rect = element.getBoundingClientRect();
- return rect.top >= 0 && rect.left >= 0 && rect.bottom <= ofElement.height && rect.right <= ofElement.width;
- } }, { key: "elVisible", value: function elVisible(
- elem) {
- if (!(elem instanceof Element)) throw Error("DomUtil: elem is not an element.");
- var style = getComputedStyle(elem);
- if (style.display === "none") return false;
- if (style.visibility !== "visible") return false;
- if (style.opacity < 0.1) return false;
- if (elem.offsetWidth + elem.offsetHeight + elem.getBoundingClientRect().height + elem.getBoundingClientRect().width === 0) {
- return false;
- }
- var elemCenter = {
- x: elem.getBoundingClientRect().left + elem.offsetWidth / 2,
- y: elem.getBoundingClientRect().top + elem.offsetHeight / 2 };
-
-
- if (elemCenter.x < 0) return false;
- if (elemCenter.x > (document.documentElement.clientWidth || window.innerWidth)) return false;
- if (elemCenter.y < 0) return false;
- if (elemCenter.y > (document.documentElement.clientHeight || window.innerHeight)) return false;
- var pointContainer = document.elementFromPoint(elemCenter.x, elemCenter.y);
- do {
- if (pointContainer === elem) return true;
- } while (pointContainer = pointContainer.parentNode);
- return false;
- } }]);return TabManager;}(React.Component);
-
-
-function debounce(func, wait, immediate) {
- var timeout;
- return function () {
- var context = this,
- args = arguments;
- var later = function later() {
- timeout = null;
- if (!immediate) func.apply(context, args);
- };
- var callNow = immediate && !timeout;
- clearTimeout(timeout);
- timeout = setTimeout(later, wait);
- if (callNow) func.apply(context, args);
- };
-}
-
-var maybePluralize = function maybePluralize(count, noun) {var suffix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 's';return (
- count + " " + noun + (count !== 1 ? suffix : ''));};
\ No newline at end of file
diff --git a/outlib/TabOptions.js b/outlib/TabOptions.js
deleted file mode 100644
index f70b5a26..00000000
--- a/outlib/TabOptions.js
+++ /dev/null
@@ -1,416 +0,0 @@
-"use strict";var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;}var
-
-TabOptions = function (_React$Component) {_inherits(TabOptions, _React$Component);
- function TabOptions(props) {_classCallCheck(this, TabOptions);var _this = _possibleConstructorReturn(this, (TabOptions.__proto__ || Object.getPrototypeOf(TabOptions)).call(this,
- props));
- _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")];
-
- return (
- React.createElement("div", { className: "logo-options" },
- React.createElement("div", { className: "logo-box" }, logo)));
-
-
- } }, { key: "optionsSection", value: function optionsSection()
- {
- var opts = [
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Tab options"),
- React.createElement("div", { className: "toggle-box" },
- React.createElement("input", {
- type: "number",
- onMouseEnter: this.props.tabLimitText,
- onChange: this.props.changeTabLimit,
- value: this.props.tabLimit,
- id: "enable_tabLimit",
- name: "enable_tabLimit" }),
-
- React.createElement("label", { onMouseEnter: this.props.tabLimitText, htmlFor: "enable_tabLimit", style: { whiteSpace: "pre", lineHeight: "2rem" } }),
- React.createElement("label", { className: "textlabel", htmlFor: "enable_tabLimit", style: { textAlign: "", whiteSpace: "pre", lineHeight: "2rem" } }, "Limit Tabs Per Window"),
-
-
- React.createElement("div", { className: "option-description" }, "Once you reach this number of tabs, Tab Manager will move new tabs to a new window instead. No more windows with 60 tabs open!",
-
- React.createElement("br", null),
- React.createElement("i", null, "By default: 0 ( disabled )"),
- React.createElement("br", null),
- React.createElement("i", null, "Suggested value: 15")))),
-
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Popup size"),
- React.createElement("div", { className: "option-description" }, "You can resize the popup here up to a maximum size of 800x600. This limitation is a browser limitation, and we cannot display a bigger popup due to this. If you want to have a better overview, instead you can right click on the Tab Manager Plus icon, and `open in own tab`. This will open the Tab Manager in a new tab."),
-
-
-
-
- React.createElement("div", { className: "toggle-box half-size float-right" },
- React.createElement("label", { className: "textlabel", htmlFor: "enable_tabWidth", style: { textAlign: "", whiteSpace: "pre", lineHeight: "2rem" } }, "Popup Width"),
-
-
- React.createElement("input", {
- type: "number",
- min: "450",
- max: "800",
- step: "25",
- onMouseEnter: this.props.tabWidthText,
- onChange: this.props.changeTabWidth,
- value: this.props.tabWidth,
- id: "enable_tabWidth",
- name: "enable_tabWidth" }),
-
- React.createElement("label", { onMouseEnter: this.props.tabWidthText, htmlFor: "enable_tabWidth", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("div", { className: "toggle-box half-size" },
- React.createElement("label", { className: "textlabel", htmlFor: "enable_tabHeight", style: { textAlign: "", whiteSpace: "pre", lineHeight: "2rem" } }, "Popup Height"),
-
-
- React.createElement("input", {
- type: "number",
- min: "400",
- max: "600",
- step: "25",
- onMouseEnter: this.props.tabHeightText,
- onChange: this.props.changeTabHeight,
- value: this.props.tabHeight,
- id: "enable_tabHeight",
- name: "enable_tabHeight" }),
-
- React.createElement("label", { onMouseEnter: this.props.tabHeightText, htmlFor: "enable_tabHeight", style: { whiteSpace: "pre", lineHeight: "2rem" } }))),
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Window style"),
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.darkText,
- onChange: this.props.toggleDark,
- checked: this.props.dark,
- id: "dark_mode",
- name: "dark_mode" }),
-
- React.createElement("label", { onMouseEnter: this.props.darkText, htmlFor: "dark_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "dark_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Dark mode"),
-
-
- React.createElement("div", { className: "option-description" }, "Dark mode, for working at night time. ",
- React.createElement("br", null),
- React.createElement("i", null, "By default: disabled"))),
-
-
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.compactText,
- onChange: this.props.toggleCompact,
- checked: this.props.compact,
- id: "compact_mode",
- name: "compact_mode" }),
-
- React.createElement("label", { onMouseEnter: this.props.compactText, htmlFor: "compact_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "compact_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Compact mode"),
-
-
- React.createElement("div", { className: "option-description" }, "Saves a little bit of space around the icons. Makes it less beautiful, but more space efficient. ",
- React.createElement("br", null),
- React.createElement("i", null, "By default: disabled"))),
-
-
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.animationsText,
- onChange: this.props.toggleAnimations,
- checked: this.props.animations,
- id: "enable_animations",
- name: "enable_animations" }),
-
- React.createElement("label", { onMouseEnter: this.props.animationsText, htmlFor: "enable_animations", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "enable_animations", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Animations"),
-
-
- React.createElement("div", { className: "option-description" }, "Disables/enables animations and transitions in the popup. ",
- React.createElement("br", null),
- React.createElement("i", null, "By default: enabled"))),
-
-
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.windowTitlesText,
- onChange: this.props.toggleWindowTitles,
- checked: this.props.windowTitles,
- id: "enable_windowTitles",
- name: "enable_windowTitles" }),
-
- React.createElement("label", { onMouseEnter: this.props.windowTitlesText, htmlFor: "enable_windowTitles", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "enable_windowTitles", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Window titles"),
-
-
- React.createElement("div", { className: "option-description" }, "Disables/enables window titles. ",
- React.createElement("br", null),
- React.createElement("i", null, "By default: enabled")))),
-
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Session Management"),
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.sessionsText,
- onChange: this.props.toggleSessions,
- checked: this.props.sessionsFeature,
- id: "session_mode",
- name: "session_mode" }),
-
- React.createElement("label", { onMouseEnter: this.props.sessionsText, htmlFor: "session_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "session_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Save Windows for Later"),
-
-
- React.createElement("div", { className: "option-description" }, "Allows you to save windows as sessions ( saved windows ). You can restore these saved windows later on. The restored windows won't have the history restored. This feature is currently in beta.",
-
-
- React.createElement("br", null),
- React.createElement("i", null, "By default: disabled ( experimental feature )"))),
-
-
- this.props.sessionsFeature && React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle-box" },
- React.createElement("label", { className: "textlabel", htmlFor: "session_export", style: { whiteSpace: "pre", lineHeight: "2rem" } },
- React.createElement("h4", null, "Export/Backup Sessions")),
-
- React.createElement("button", { type: "button", onMouseEnter: this.props.exportSessionsText, onClick: this.props.exportSessions, id: "session_export", name: "session_export" }, "Export/Backup Sessions"),
-
-
- React.createElement("label", { onMouseEnter: this.props.exportSessionsText, htmlFor: "session_export", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("div", { className: "option-description" }, "Allows you to backup your saved windows to an external file.")),
-
- this.props.sessionsFeature && React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle-box" },
- React.createElement("label", { className: "textlabel", htmlFor: "session_import", style: { whiteSpace: "pre", lineHeight: "2rem" } },
- React.createElement("h4", null, "Import/Restore Sessions")),
-
- React.createElement("input", {
- type: "file",
- accept: "application/json",
- onMouseEnter: this.props.importSessionsText,
- onChange: this.props.importSessions,
- id: "session_import",
- name: "session_import",
- placeholder: "Import/Restore Sessions" }),
-
- React.createElement("label", { onMouseEnter: this.props.importSessionsText, htmlFor: "session_import", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("div", { className: "option-description" }, "Allows you to restore your backup from an external file. The restored windows will be added to your current saved windows."))),
-
-
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Popup icon"),
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.badgeText,
- onChange: this.props.toggleBadge,
- checked: this.props.badge,
- id: "badge_mode",
- name: "badge_mode" }),
-
- React.createElement("label", { onMouseEnter: this.props.badgeText, htmlFor: "badge_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "badge_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Count Tabs"),
-
-
- React.createElement("div", { className: "option-description" }, "Shows you the number of open tabs over the Tab Manager icon in the top right of your browser.",
-
- React.createElement("br", null),
- React.createElement("i", null, "By default: enabled"))),
-
-
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.openInOwnTabText,
- onChange: this.props.toggleOpenInOwnTab,
- checked: this.props.openInOwnTab,
- id: "openinowntab_mode",
- name: "openinowntab_mode" }),
-
- React.createElement("label", { onMouseEnter: this.props.openInOwnTabText, htmlFor: "openinowntab_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "openinowntab_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Open in own Tab by default"),
-
-
- React.createElement("div", { className: "option-description" }, "Opens the Tab Manager in own tab by default, instead of the popup.",
-
- React.createElement("br", null),
- React.createElement("i", null, "By default: disabled")))),
-
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Window settings"),
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.hideText,
- onChange: this.props.toggleHide,
- checked: this.props.hideWindows,
- id: "auto_hide",
- name: "auto_hide" }),
-
- React.createElement("label", { onMouseEnter: this.props.hideText, htmlFor: "auto_hide", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "auto_hide", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Minimize inactive windows"),
-
-
- React.createElement("div", { className: "option-description" }, "With this option enabled, you will only have 1 open window per monitor at all times. When you switch to another window, the other windows will be minimized to the tray automatically.",
-
-
- React.createElement("br", null),
- React.createElement("i", null, "By default: disabled"))),
-
-
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.tabActionsText,
- onChange: this.props.toggleTabActions,
- checked: this.props.tabactions,
- id: "tabactions_mode",
- name: "tabactions_mode" }),
-
- React.createElement("label", { onMouseEnter: this.props.tabActionsText, htmlFor: "tabactions_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "tabactions_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Show action buttons"),
-
-
- React.createElement("div", { className: "option-description" }, "Displays buttons in every window for : opening a new tab, minimizing the window, assigning a color to the window and closing the window.",
-
- React.createElement("br", null),
- React.createElement("i", null, "By default: enabled")))),
-
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Advanced settings"),
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle-box" },
- React.createElement("a", { href: "#", onClick: this.openIncognitoOptions }, "Allow in Incognito")),
-
-
-
- React.createElement("div", { className: "option-description" }, "If you also want to see your incognito tabs in the Tab Manager overview, then enable incognito access for this extension.")),
-
-
-
- React.createElement("div", { className: "toggle-box" },
- React.createElement("a", { href: "#", onClick: this.openShortcuts }, "Change shortcut key"),
-
-
- React.createElement("div", { className: "option-description" }, "If you want to disable or change the shortcut key with which to open Tab Manager Plus, you can do so here."))),
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("div", { className: "toggle-box" },
- React.createElement("h4", null, "Right mouse button"),
- React.createElement("div", { className: "option-description" }, "With the right mouse button you can select tabs"),
- React.createElement("h4", null, "Shift+Right mouse button"),
- React.createElement("div", { className: "option-description" }, "While holding shift, and pressing the right mouse button you can select all tabs between the last selected tab and the current one"),
-
-
- React.createElement("h4", null, "Middle mouse button"),
- React.createElement("div", { className: "option-description" }, "With the middle mouse button you can close a tab"),
- React.createElement("h4", null, "[Enter / Return] button"),
- React.createElement("div", { className: "option-description" }, "With the return button you can switch to the currently selected tab, or move multiple selected tabs to a new window")))];
-
-
-
-
-
-
- return React.createElement("div", { className: "toggle-options" }, opts);
- } }, { key: "openIncognitoOptions", value: function openIncognitoOptions()
- {
- browser.tabs.create({
- url: "chrome://extensions/?id=cnkdjjdmfiffagllbiiilooaoofcoeff" });
-
- } }, { key: "openShortcuts", value: function openShortcuts()
- {
- browser.tabs.create({ url: "chrome://extensions/shortcuts" });
- } }, { key: "licenses", value: function licenses()
- {
- var licenses = [];
- licenses.push(
- React.createElement("div", { className: "license" }, "Tab Manager Plus is based on",
- " ",
- React.createElement("a", { href: "https://github.com/dsc/Tab-Manager", target: "_blank", title: "Tab-Manager" }, "dsc/Tab-Manager"), ",",
-
-
- " ",
- React.createElement("a", { href: "https://github.com/joshperry/Tab-Manager", target: "_blank", title: "Tab-Manager" }, "joshperry/Tab-Manager"),
-
- " ", "and",
- " ",
- React.createElement("a", { href: "https://github.com/JonasNo/Tab-Manager", target: "_blank", title: "Tab-Manager" }, "JonasNo/Tab-Manager"), ".",
-
-
- React.createElement("br", null), "Licensed by",
- " ",
- React.createElement("a", { href: "http://creativecommons.org/licenses/by/3.0/", target: "_blank", title: " Mozilla Public License (MPL)" }, "MPLv2"), ". Icons made by",
-
-
- " ",
- React.createElement("a", { href: "http://www.freepik.com", title: "Freepik" }, "Freepik"),
-
- " ", "from",
- " ",
- React.createElement("a", { href: "http://www.flaticon.com", title: "Flaticon" }, "www.flaticon.com"), ". Licensed by",
-
-
- " ",
- React.createElement("a", { href: "http://creativecommons.org/licenses/by/3.0/", target: "_blank", title: "Creative Commons BY 3.0" }, "CC 3.0 BY"), "."));
-
-
-
-
-
-
- return React.createElement("div", { className: "licenses" }, licenses);
- } }, { key: "render", value: function render()
- {
- var children = [];
-
- children.push(this.logo());
- children.push(this.optionsSection());
- children.push(React.createElement("div", { className: "clearfix" }));
- //children.push(React.createElement('h4', {}, this.props.getTip()));
- children.push(this.licenses());
-
- return (
- React.createElement("div", { className: "options-window" },
- React.createElement("div", null, children)));
-
-
- } }]);return TabOptions;}(React.Component);
\ No newline at end of file
diff --git a/outlib/TabOptionsFirefox.js b/outlib/TabOptionsFirefox.js
deleted file mode 100644
index 04570fff..00000000
--- a/outlib/TabOptionsFirefox.js
+++ /dev/null
@@ -1,397 +0,0 @@
-"use strict";var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;}var
-
-TabOptions = function (_React$Component) {_inherits(TabOptions, _React$Component);
- function TabOptions(props) {_classCallCheck(this, TabOptions);var _this = _possibleConstructorReturn(this, (TabOptions.__proto__ || Object.getPrototypeOf(TabOptions)).call(this,
- props));
- _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")];
-
- return (
- React.createElement("div", { className: "logo-options" },
- React.createElement("div", { className: "logo-box" }, logo)));
-
-
- } }, { key: "optionsSection", value: function optionsSection()
- {
- var opts = [
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Tab options"),
- React.createElement("div", { className: "toggle-box" },
- React.createElement("input", {
- type: "number",
- onMouseEnter: this.props.tabLimitText,
- onChange: this.props.changeTabLimit,
- value: this.props.tabLimit,
- id: "enable_tabLimit",
- name: "enable_tabLimit" }),
-
- React.createElement("label", { onMouseEnter: this.props.tabLimitText, htmlFor: "enable_tabLimit", style: { whiteSpace: "pre", lineHeight: "2rem" } }),
- React.createElement("label", { className: "textlabel", htmlFor: "enable_tabLimit", style: { textAlign: "", whiteSpace: "pre", lineHeight: "2rem" } }, "Limit Tabs Per Window"),
-
-
- React.createElement("div", { className: "option-description" }, "Once you reach this number of tabs, Tab Manager will move new tabs to a new window instead. No more windows with 60 tabs open!",
-
- React.createElement("br", null),
- React.createElement("i", null, "By default: 0 ( disabled )"),
- React.createElement("br", null),
- React.createElement("i", null, "Suggested value: 15")))),
-
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Popup size"),
- React.createElement("div", { className: "option-description" }, "You can resize the popup here up to a maximum size of 800x600. This limitation is a browser limitation, and we cannot display a bigger popup due to this. If you want to have a better overview, instead you can right click on the Tab Manager Plus icon, and `open in own tab`. This will open the Tab Manager in a new tab."),
-
-
-
-
- React.createElement("div", { className: "toggle-box half-size float-right" },
- React.createElement("label", { className: "textlabel", htmlFor: "enable_tabWidth", style: { textAlign: "", whiteSpace: "pre", lineHeight: "2rem" } }, "Popup Width"),
-
-
- React.createElement("input", {
- type: "number",
- min: "450",
- max: "800",
- step: "25",
- onMouseEnter: this.props.tabWidthText,
- onChange: this.props.changeTabWidth,
- value: this.props.tabWidth,
- id: "enable_tabWidth",
- name: "enable_tabWidth" }),
-
- React.createElement("label", { onMouseEnter: this.props.tabWidthText, htmlFor: "enable_tabWidth", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("div", { className: "toggle-box half-size" },
- React.createElement("label", { className: "textlabel", htmlFor: "enable_tabHeight", style: { textAlign: "", whiteSpace: "pre", lineHeight: "2rem" } }, "Popup Height"),
-
-
- React.createElement("input", {
- type: "number",
- min: "400",
- max: "600",
- step: "25",
- onMouseEnter: this.props.tabHeightText,
- onChange: this.props.changeTabHeight,
- value: this.props.tabHeight,
- id: "enable_tabHeight",
- name: "enable_tabHeight" }),
-
- React.createElement("label", { onMouseEnter: this.props.tabHeightText, htmlFor: "enable_tabHeight", style: { whiteSpace: "pre", lineHeight: "2rem" } }))),
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Window style"),
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.darkText,
- onChange: this.props.toggleDark,
- checked: this.props.dark,
- id: "dark_mode",
- name: "dark_mode" }),
-
- React.createElement("label", { onMouseEnter: this.props.darkText, htmlFor: "dark_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "dark_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Dark mode"),
-
-
- React.createElement("div", { className: "option-description" }, "Dark mode, for working at night time. ",
- React.createElement("br", null),
- React.createElement("i", null, "By default: disabled"))),
-
-
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.compactText,
- onChange: this.props.toggleCompact,
- checked: this.props.compact,
- id: "compact_mode",
- name: "compact_mode" }),
-
- React.createElement("label", { onMouseEnter: this.props.compactText, htmlFor: "compact_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "compact_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Compact mode"),
-
-
- React.createElement("div", { className: "option-description" }, "Saves a little bit of space around the icons. Makes it less beautiful, but more space efficient. ",
- React.createElement("br", null),
- React.createElement("i", null, "By default: disabled"))),
-
-
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.animationsText,
- onChange: this.props.toggleAnimations,
- checked: this.props.animations,
- id: "enable_animations",
- name: "enable_animations" }),
-
- React.createElement("label", { onMouseEnter: this.props.animationsText, htmlFor: "enable_animations", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "enable_animations", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Animations"),
-
-
- React.createElement("div", { className: "option-description" }, "Disables/enables animations and transitions in the popup. ",
- React.createElement("br", null),
- React.createElement("i", null, "By default: enabled"))),
-
-
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.windowTitlesText,
- onChange: this.props.toggleWindowTitles,
- checked: this.props.windowTitles,
- id: "enable_windowTitles",
- name: "enable_windowTitles" }),
-
- React.createElement("label", { onMouseEnter: this.props.windowTitlesText, htmlFor: "enable_windowTitles", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "enable_windowTitles", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Window titles"),
-
-
- React.createElement("div", { className: "option-description" }, "Disables/enables window titles. ",
- React.createElement("br", null),
- React.createElement("i", null, "By default: enabled")))),
-
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Session Management"),
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.sessionsText,
- onChange: this.props.toggleSessions,
- checked: this.props.sessionsFeature,
- id: "session_mode",
- name: "session_mode" }),
-
- React.createElement("label", { onMouseEnter: this.props.sessionsText, htmlFor: "session_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "session_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Save Windows for Later"),
-
-
- React.createElement("div", { className: "option-description" }, "Allows you to save windows as sessions ( saved windows ). You can restore these saved windows later on. The restored windows won't have the history restored. This feature is currently in beta.",
-
-
- React.createElement("br", null),
- React.createElement("i", null, "By default: disabled ( experimental feature )"))),
-
-
- this.props.sessionsFeature && React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle-box" },
- React.createElement("label", { className: "textlabel", htmlFor: "session_export", style: { whiteSpace: "pre", lineHeight: "2rem" } },
- React.createElement("h4", null, "Export/Backup Sessions")),
-
- React.createElement("button", { type: "button", onMouseEnter: this.props.exportSessionsText, onClick: this.props.exportSessions, id: "session_export", name: "session_export" }, "Export/Backup Sessions"),
-
-
- React.createElement("label", { onMouseEnter: this.props.exportSessionsText, htmlFor: "session_export", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("div", { className: "option-description" }, "Allows you to backup your saved windows to an external file.")),
-
- this.props.sessionsFeature && React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle-box" },
- React.createElement("label", { className: "textlabel", htmlFor: "session_import", style: { whiteSpace: "pre", lineHeight: "2rem" } },
- React.createElement("h4", null, "Import/Restore Sessions")),
-
- React.createElement("input", {
- type: "file",
- accept: "application/json",
- onMouseEnter: this.props.importSessionsText,
- onChange: this.props.importSessions,
- id: "session_import",
- name: "session_import",
- placeholder: "Import/Restore Sessions" }),
-
- React.createElement("label", { onMouseEnter: this.props.importSessionsText, htmlFor: "session_import", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("div", { className: "option-description" }, "Allows you to restore your backup from an external file. The restored windows will be added to your current saved windows."))),
-
-
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Popup icon"),
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.badgeText,
- onChange: this.props.toggleBadge,
- checked: this.props.badge,
- id: "badge_mode",
- name: "badge_mode" }),
-
- React.createElement("label", { onMouseEnter: this.props.badgeText, htmlFor: "badge_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "badge_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Count Tabs"),
-
-
- React.createElement("div", { className: "option-description" }, "Shows you the number of open tabs over the Tab Manager icon in the top right of your browser.",
-
- React.createElement("br", null),
- React.createElement("i", null, "By default: enabled"))),
-
-
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.openInOwnTabText,
- onChange: this.props.toggleOpenInOwnTab,
- checked: this.props.openInOwnTab,
- id: "openinowntab_mode",
- name: "openinowntab_mode" }),
-
- React.createElement("label", { onMouseEnter: this.props.openInOwnTabText, htmlFor: "openinowntab_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "openinowntab_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Open in own Tab by default"),
-
-
- React.createElement("div", { className: "option-description" }, "Opens the Tab Manager in own tab by default, instead of the popup.",
-
- React.createElement("br", null),
- React.createElement("i", null, "By default: disabled")))),
-
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Window settings"),
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle" },
- React.createElement("input", {
- type: "checkbox",
- onMouseEnter: this.props.tabActionsText,
- onChange: this.props.toggleTabActions,
- checked: this.props.tabactions,
- id: "tabactions_mode",
- name: "tabactions_mode" }),
-
- React.createElement("label", { onMouseEnter: this.props.tabActionsText, htmlFor: "tabactions_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } })),
-
- React.createElement("label", { className: "textlabel", htmlFor: "tabactions_mode", style: { whiteSpace: "pre", lineHeight: "2rem" } }, "Show action buttons"),
-
-
- React.createElement("div", { className: "option-description" }, "Displays buttons in every window for : opening a new tab, minimizing the window, assigning a color to the window and closing the window.",
-
- React.createElement("br", null),
- React.createElement("i", null, "By default: enabled")))),
-
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("h4", null, "Advanced settings"),
- React.createElement("div", { className: "toggle-box" },
- React.createElement("div", { className: "toggle-box" },
- React.createElement("a", { href: "#", onClick: this.openIncognitoOptions }, "Allow in Private Windows")),
-
-
-
- React.createElement("div", { className: "option-description" }, "If you also want to see your private tabs in the Tab Manager overview, then enable private windows access for this extension.")),
-
-
-
- React.createElement("div", { className: "toggle-box" },
- React.createElement("a", { href: "#", onClick: this.openShortcuts }, "Change shortcut key"),
-
-
- React.createElement("div", { className: "option-description" }, "If you want to disable or change the shortcut key with which to open Tab Manager Plus, you can do so in the add-ons settings. Click on the settings cog on the next page, and then 'Manage Extension Shortcuts'."))),
-
-
-
-
-
- React.createElement("div", { className: "optionsBox" },
- React.createElement("div", { className: "toggle-box" },
- React.createElement("h4", null, "Right mouse button"),
- React.createElement("div", { className: "option-description" }, "With the right mouse button you can select tabs"),
- React.createElement("h4", null, "Shift+Right mouse button"),
- React.createElement("div", { className: "option-description" }, "While holding shift, and pressing the right mouse button you can select all tabs between the last selected tab and the current one"),
-
-
- React.createElement("h4", null, "Middle mouse button"),
- React.createElement("div", { className: "option-description" }, "With the middle mouse button you can close a tab"),
- React.createElement("h4", null, "[Enter / Return] button"),
- React.createElement("div", { className: "option-description" }, "With the return button you can switch to the currently selected tab, or move multiple selected tabs to a new window")))];
-
-
-
-
-
-
- return React.createElement("div", { className: "toggle-options" }, opts);
- } }, { key: "openIncognitoOptions", value: function openIncognitoOptions()
- {
- browser.runtime.openOptionsPage();
- // browser.tabs.create({ url: 'about:addons' });
- } }, { key: "openShortcuts", value: function openShortcuts()
- {
- browser.runtime.openOptionsPage();
- //browser.tabs.create({ url: 'about:addons' });
- } }, { key: "licenses", value: function licenses()
- {
- var licenses = [];
- licenses.push(
- React.createElement("div", { className: "license" }, "Tab Manager Plus is based on",
- " ",
- React.createElement("a", { href: "https://github.com/dsc/Tab-Manager", target: "_blank", title: "Tab-Manager" }, "dsc/Tab-Manager"), ",",
-
-
- " ",
- React.createElement("a", { href: "https://github.com/joshperry/Tab-Manager", target: "_blank", title: "Tab-Manager" }, "joshperry/Tab-Manager"),
-
- " ", "and",
- " ",
- React.createElement("a", { href: "https://github.com/JonasNo/Tab-Manager", target: "_blank", title: "Tab-Manager" }, "JonasNo/Tab-Manager"), ".",
-
-
- React.createElement("br", null), "Licensed by",
- " ",
- React.createElement("a", { href: "http://creativecommons.org/licenses/by/3.0/", target: "_blank", title: " Mozilla Public License (MPL)" }, "MPLv2"), ". Icons made by",
-
-
- " ",
- React.createElement("a", { href: "http://www.freepik.com", title: "Freepik" }, "Freepik"),
-
- " ", "from",
- " ",
- React.createElement("a", { href: "http://www.flaticon.com", title: "Flaticon" }, "www.flaticon.com"), ". Licensed by",
-
-
- " ",
- React.createElement("a", { href: "http://creativecommons.org/licenses/by/3.0/", target: "_blank", title: "Creative Commons BY 3.0" }, "CC 3.0 BY"), "."));
-
-
-
-
-
-
- return React.createElement("div", { className: "licenses" }, licenses);
- } }, { key: "render", value: function render()
- {
- var children = [];
-
- children.push(this.logo());
- children.push(this.optionsSection());
- children.push(React.createElement("div", { className: "clearfix" }));
- //children.push(React.createElement('h4', {}, this.props.getTip()));
- children.push(this.licenses());
-
- return (
- React.createElement("div", { className: "options-window" },
- React.createElement("div", null, children)));
-
-
- } }]);return TabOptions;}(React.Component);
\ No newline at end of file
diff --git a/outlib/Window.js b/outlib/Window.js
deleted file mode 100644
index b3441c58..00000000
--- a/outlib/Window.js
+++ /dev/null
@@ -1,663 +0,0 @@
-"use strict";var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};}function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;}var
-
-Window = function (_React$Component) {_inherits(Window, _React$Component);
- function Window(props) {_classCallCheck(this, Window);var _this2 = _possibleConstructorReturn(this, (Window.__proto__ || Object.getPrototypeOf(Window)).call(this,
- props));
- var colors = localStorage["windowColors"];
- if (!!colors) {
- colors = JSON.parse(colors);
- } else {
- colors = {};
- }
- var color = colors[_this2.props.window.id] || "default";
- var names = localStorage["windowNames"];
- if (!!names) {
- names = JSON.parse(names);
- } else {
- names = {};
- }
- var name = names[_this2.props.window.id] || "";
- if (!!_this2.props.window.titlePreface) {
- name = _this2.props.window.titlePreface;
- }
- _this2.state = {
- colorActive: false,
- windowTitles: [],
- color: color,
- name: name,
- tabs: 0 };
-
-
- _this2.addTab = _this2.addTab.bind(_this2);
- _this2.changeColors = _this2.changeColors.bind(_this2);
- _this2.changeName = _this2.changeName.bind(_this2);
- _this2.checkKey = _this2.checkKey.bind(_this2);
- _this2.closePopup = _this2.closePopup.bind(_this2);
- _this2.close = _this2.close.bind(_this2);
- _this2.colors = _this2.colors.bind(_this2);
- _this2.dragOver = _this2.dragOver.bind(_this2);
- _this2.drop = _this2.drop.bind(_this2);
- _this2.maximize = _this2.maximize.bind(_this2);
- _this2.minimize = _this2.minimize.bind(_this2);
- _this2.save = _this2.save.bind(_this2);
- _this2.stop = _this2.stop.bind(_this2);
- _this2.windowClick = _this2.windowClick.bind(_this2);
- _this2.selectToFromTab = _this2.selectToFromTab.bind(_this2);return _this2;
- }_createClass(Window, [{ key: "render", value: function render()
-
- {
- var _this = this;
- var colors = localStorage["windowColors"];
- if (!!colors) {
- colors = JSON.parse(colors);
- } else {
- colors = {};
- }
- var color = colors[this.props.window.id] || "default";
- var names = localStorage["windowNames"];
- if (!!names) {
- names = JSON.parse(names);
- } else {
- names = {};
- }
- var name = names[this.props.window.id] || "";
- var hideWindow = true;
- var titleAdded = false;
- var tabsperrow = this.props.layout.indexOf("blocks") > -1 ? Math.ceil(Math.sqrt(this.props.tabs.length + 2)) : this.props.layout == "vertical" ? 1 : 15;
- var tabs = this.props.tabs.map(function (tab) {
- var isHidden = !!_this.props.hiddenTabs[tab.id] && _this.props.filterTabs;
- var isSelected = !!_this.props.selection[tab.id];
- hideWindow &= isHidden;
- return (
- React.createElement(Tab, {
- key: "windowtab_" + _this.props.window.id + "_" + tab.id,
- window: _this.props.window,
- layout: _this.props.layout,
- tab: tab,
- selected: isSelected,
- hidden: isHidden,
- middleClick: _this.props.tabMiddleClick,
- hoverHandler: _this.props.hoverHandler,
- searchActive: _this.props.searchActive,
- select: _this.props.select,
- selectTo: _this.selectToFromTab,
- drag: _this.props.drag,
- drop: _this.props.drop,
- dropWindow: _this.props.dropWindow,
- ref: "tab" + tab.id,
- id: "tab-" + tab.id }));
-
-
- });
- if (!hideWindow) {
- if (!!this.props.tabactions) {
- tabs.push(
- React.createElement("div", { className: "newliner" }),
- React.createElement("div", { className: "window-actions" },
- this.props.sessionsFeature ?
- React.createElement("div", {
- className: "icon tabaction save " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title:
- "Save this window for later\nWill save " +
- tabs.length +
- " tabs with this window for later. Please note : The saved tabs will lose their history.",
-
- onClick: this.save,
- onMouseEnter: this.props.hoverIcon }) :
-
-
- false,
-
- React.createElement("div", {
- className: "icon tabaction add " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Open a new tab",
- onClick: this.addTab,
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction colors " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change window name or color",
- onClick: this.colors,
- onMouseEnter: this.props.hoverIcon }),
-
- this.props.window.state == "minimized" ?
- React.createElement("div", {
- className: "icon tabaction maximize " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Maximize this window\nWill maximize " + tabs.length + " tabs",
- onClick: this.maximize,
- onMouseEnter: this.props.hoverIcon }) :
-
-
- React.createElement("div", {
- className: "icon tabaction minimize " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Minimize this window\nWill minimize " + tabs.length + " tabs",
- onClick: this.minimize,
- onMouseEnter: this.props.hoverIcon }),
-
-
- React.createElement("div", {
- className: "icon tabaction close " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Close this window\nWill close " + tabs.length + " tabs",
- onClick: this.close,
- onMouseEnter: this.props.hoverIcon })));
-
-
-
- }
- if (this.state.colorActive) {
- tabs.push(
- React.createElement("div", { className: "window-colors " + (this.state.colorActive ? "" : "hidden"), onClick: this.stop, onKeyDown: this.checkKey },
- React.createElement("h2", { className: "window-x", onClick: this.closePopup }, "x"),
-
-
- React.createElement("h3", { className: "center" }, "Name the window"),
- React.createElement("input", {
- className: "window-name-input",
- type: "text",
- onChange: this.changeName,
- value: this.state.name,
- placeholder: this.state.windowTitles ? this.topEntries(this.state.windowTitles).join("") : "Name window...",
- tabIndex: "1",
- ref: "namebox",
- onKeyDown: this.checkKey }),
-
- React.createElement("h3", { className: "center" }, "Pick a color"),
- React.createElement("div", { className: "colors-box" },
- React.createElement("div", {
- className: "icon tabaction default " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "default" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color1 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color1" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color2 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color2" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color3 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color3" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color4 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color4" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color5 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color5" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color6 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color6" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color7 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color7" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color8 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color8" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color9 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color9" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color10 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color10" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color11 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color11" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color12 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color12" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color13 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color13" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color14 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color14" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color15 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color15" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color16 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color16" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color17 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color17" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color18 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color18" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color19 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color19" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color20 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color20" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color21 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color21" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color22 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color22" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color23 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color23" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color24 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color24" }),
- onMouseEnter: this.props.hoverIcon }),
-
- React.createElement("div", {
- className: "icon tabaction color25 " + (this.props.layout.indexOf("blocks") > -1 ? "" : "windowaction"),
- title: "Change background color",
- onClick: this.changeColors.bind(this, { colorActive: false, color: "color25" }),
- onMouseEnter: this.props.hoverIcon }))));
-
-
-
-
- }
-
- if (this.props.windowTitles) {
- if (name) {
- tabs.unshift(
- React.createElement("h3", {
- key: "window-" + this.props.window.id + "-windowTitle",
- className: "editName center windowTitle",
- onClick: this.colors,
- title: "Change the name of this window",
- onMouseEnter: this.props.hoverIcon },
-
- name));
-
-
- titleAdded = true;
- } else {
- if (this.state.windowTitles.length == 0 || this.state.tabs != tabs.length + this.props.window.id * 99) {
- 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;
- } else if (protocol.indexOf("about") > -1) {
- hostname = tabs[i].props.tab.title;
- } else if (hostname.indexOf("mail.google") > -1) {
- hostname = "gmail";
- } else {
- hostname = hostname.replace("www.", "");
- var regex_var = new RegExp(/(\.[^\.]{0,2})(\.[^\.]{0,2})(\.*$)|(\.[^\.]*)(\.*$)/);
- hostname = hostname.
- replace(regex_var, "").
- split(".").
- pop();
- }
- if (hostname.length > 18) {
- hostname = tabs[i].props.tab.title;
- while (hostname.length > 18 && hostname.indexOf(" ") > -1) {
- hostname = hostname.split(" ");
- hostname.pop();
- hostname = hostname.join(" ");
- }
- }
- this.state.windowTitles.push(hostname);
- }
- }
- }
-
- if (this.state.windowTitles.length > 0) {
- tabs.unshift(
- React.createElement("h3", {
- key: "window-" + this.props.window.id + "-windowTitle",
- className: "editName center windowTitle",
- onClick: this.colors,
- title: "Change the name of this window",
- onMouseEnter: this.props.hoverIcon },
-
- this.topEntries(this.state.windowTitles).join("")));
-
-
- titleAdded = true;
- }
- }
- }
-
- if (tabsperrow < 5) {
- tabsperrow = 5;
- }
- var children = [];
- if (!!titleAdded) {
- children.push(tabs.shift());
- }
- var z = -1;
- for (var j = 0; j < tabs.length; j++) {
- var tab = tabs[j].props.tab;
- var isHidden = !!tab && !!tab.id && !!this.props.hiddenTabs[tab.id] && this.props.filterTabs;
- if (!isHidden) {
- z++;
- children.push(tabs[j]);
- }
- if ((z + 1) % tabsperrow == 0 && z && this.props.layout.indexOf("blocks") > -1) {
- children.push(React.createElement("div", { className: "newliner" }));
- }
- }
- var focused = false;
- if (this.props.window.focused || this.props.lastOpenWindow == this.props.window.id) {
- focused = true;
- }
- return (
- React.createElement("div", {
- key: "window-" + this.props.window.id,
- id: "window-" + this.props.window.id,
- className:
- "window " +
- this.props.window.state +
- " window-" +
- this.props.window.id +
- " " + (
- focused ? "activeWindow" : "") +
- " " +
- color +
- " " + (
- this.props.layout.indexOf("blocks") > -1 ? "block" : "") +
- " " +
- this.props.layout +
- " " + (
- this.props.window.incognito ? " incognito" : "") +
- " " + (
- focused ? " focused" : ""),
-
- onDragOver: this.dragOver,
- onClick: this.windowClick,
- title: "Focus this window\nWill select this window with " + tabs.length + " tabs",
- onMouseEnter: this.props.hoverIcon,
- onDrop: this.drop },
-
- React.createElement("div", { className: "windowcontainer", title: "Focus this window\nWill select this window with " + tabs.length + " tabs" }, children)));
-
-
- } else {
- return null;
- }
- } }, { key: "stop", value: function stop(
- e) {
- this.stopProp(e);
- } }, { key: "addTab", value: function addTab(
- e) {
- this.stopProp(e);
- browser.tabs.create({ windowId: this.props.window.id });
- } }, { key: "dragOver", value: function dragOver(
- e) {
- this.stopProp(e);
- } }, { key: "drop", value: function drop(
- e) {
- this.stopProp(e);
- this.props.dropWindow(this.props.window.id);
- } }, { key: "checkKey", value: function checkKey(
- e) {
- // close popup when enter or escape have been pressed
- if (e.keyCode == 13 || e.keyCode == 27) {
- this.stopProp(e);
- this.closePopup();
- }
- } }, { key: "windowClick", value: function () {var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(
- e) {var backgroundPage, windowId;return regeneratorRuntime.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:
- this.stopProp(e);_context.next = 3;return (
- browser.runtime.getBackgroundPage());case 3:backgroundPage = _context.sent;
- windowId = this.props.window.id;
- if (navigator.userAgent.search("Firefox") > -1) {
- backgroundPage.focusOnWindowDelayed(windowId);
- } else {
- backgroundPage.focusOnWindow(windowId);
- }
- this.props.parentUpdate();
- if (!!window.inPopup) window.close();return _context.abrupt("return",
- false);case 9:case "end":return _context.stop();}}}, _callee, this);}));function windowClick(_x) {return _ref.apply(this, arguments);}return windowClick;}() }, { key: "selectToFromTab", value: function selectToFromTab(
-
- tabId) {
- if (tabId) this.props.selectTo(tabId, this.props.tabs);
- } }, { key: "close", value: function close(
- e) {
- this.stopProp(e);
- browser.windows.remove(this.props.window.id);
- } }, { key: "uuidv4", value: function uuidv4()
- {
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
- var r = Math.random() * 16 | 0,
- v = c == "x" ? r : r & 0x3 | 0x8;
- return v.toString(16);
- });
- } }, { key: "save", value: function () {var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(
- e) {var sessionName, session, queryInfo, tabs, tabkey, newTab, obj, value;return regeneratorRuntime.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:
- this.stopProp(e);
-
- console.log("session name", this.state.name);
- sessionName = this.state.name || this.topEntries(this.state.windowTitles).join("");
- console.log("session name", sessionName);
-
- session = {
- tabs: [],
- windowsInfo: {},
- name: sessionName,
- date: Date.now(),
- sessionStartTime: Date.now(),
- id: this.uuidv4() };
-
-
- if (this.state.name) {
- session.customName = true;
- }
-
- queryInfo = {};
- //queryInfo.currentWindow = true;
- queryInfo.windowId = this.props.window.id;
- console.log(queryInfo);_context2.next = 11;return (
-
- browser.tabs.query(queryInfo));case 11:tabs = _context2.sent;
- console.log(tabs);_context2.t0 = regeneratorRuntime.keys(
- tabs);case 14:if ((_context2.t1 = _context2.t0()).done) {_context2.next = 23;break;}tabkey = _context2.t1.value;if (!(
- navigator.userAgent.search("Firefox") > -1)) {_context2.next = 20;break;}
- newTab = tabs[tabkey];if (!(
- !!newTab.url && newTab.url.search("about:") > -1)) {_context2.next = 20;break;}return _context2.abrupt("continue", 14);case 20:
-
-
-
- session.tabs.push(tabs[tabkey]);_context2.next = 14;break;case 23:
-
- console.log(session.tabs);_context2.next = 26;return (
- browser.windows.get(this.props.window.id));case 26:session.windowsInfo = _context2.sent;
-
- console.log(session);
- obj = {};
- obj[session.id] = session;
- console.log(obj);_context2.next = 33;return (
-
- browser.storage.local.set(obj).catch(function (err) {
- console.log(err);
- console.error(err.message);
- }));case 33:value = _context2.sent;
- this.props.parentUpdate();
- console.log("Value is set to " + value);
-
- setTimeout(function () {
- this.props.scrollTo("session", session.id);
- }.bind(this), 250);case 37:case "end":return _context2.stop();}}}, _callee2, this);}));function save(_x2) {return _ref2.apply(this, arguments);}return save;}() }, { key: "minimize", value: function () {var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(
-
- e) {return regeneratorRuntime.wrap(function _callee3$(_context3) {while (1) {switch (_context3.prev = _context3.next) {case 0:
- this.stopProp(e);_context3.next = 3;return (
- browser.windows.update(this.props.window.id, {
- state: "minimized" }));case 3:
-
- this.props.parentUpdate();case 4:case "end":return _context3.stop();}}}, _callee3, this);}));function minimize(_x3) {return _ref3.apply(this, arguments);}return minimize;}() }, { key: "maximize", value: function () {var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(
-
- e) {return regeneratorRuntime.wrap(function _callee4$(_context4) {while (1) {switch (_context4.prev = _context4.next) {case 0:
- this.stopProp(e);_context4.next = 3;return (
- browser.windows.update(this.props.window.id, {
- state: "normal" }));case 3:
-
- this.props.parentUpdate();case 4:case "end":return _context4.stop();}}}, _callee4, this);}));function maximize(_x4) {return _ref4.apply(this, arguments);}return maximize;}() }, { key: "colors", value: function colors(
-
- e) {
- this.stopProp(e);
- this.props.toggleColors(!this.state.colorActive, this.props.window.id);
- this.setState({
- colorActive: !this.state.colorActive });
-
- setTimeout(function () {
- if (this.state.colorActive) {
- this.refs.namebox.focus();
- }
- }.bind(this), 250);
- } }, { key: "changeColors", value: function changeColors(
- a) {
- this.setState(a);
- var colors = localStorage["windowColors"];
- if (!!colors) {
- colors = JSON.parse(colors);
- } else {
- colors = {};
- }
- colors[this.props.window.id] = a.color;
- localStorage["windowColors"] = JSON.stringify(colors);
- } }, { key: "closePopup", value: function closePopup()
- {
- this.props.toggleColors(!this.state.colorActive, this.props.window.id);
- this.setState({
- colorActive: !this.state.colorActive });
-
- this.props.parentUpdate();
- } }, { key: "changeName", value: function () {var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(
- e) {var name, names;return regeneratorRuntime.wrap(function _callee5$(_context5) {while (1) {switch (_context5.prev = _context5.next) {case 0:
- // this.setState(a);
- name = "";
- if (e && e.target && e.target.value) name = e.target.value;
-
- names = localStorage["windowNames"];
- if (!!names) {
- names = JSON.parse(names);
- } else {
- names = {};
- }
- names[this.props.window.id] = name;
- localStorage["windowNames"] = JSON.stringify(names);
- this.setState({
- name: name });
-
- if (navigator.userAgent.search("Firefox") > -1) {
- if (!!name) {
- browser.windows.update(this.props.window.id, {
- titlePreface: name + " - " });
-
- } else {
- browser.windows.update(this.props.window.id, {
- titlePreface: name });
-
- }
- }case 8:case "end":return _context5.stop();}}}, _callee5, this);}));function changeName(_x5) {return _ref5.apply(this, arguments);}return changeName;}() }, { key: "topEntries", value: function topEntries(
-
- arr) {
- var cnts = arr.reduce(function (obj, val) {
- obj[val] = (obj[val] || 0) + 1;
- return obj;
- }, {});
- var sorted = Object.keys(cnts).sort(function (a, b) {
- return cnts[b] - cnts[a];
- });
-
- var more = 0;
- if (sorted.length == 3) {
- } else {
- while (sorted.length > 2) {
- sorted.pop();
- more++;
- }
- }
- for (var i = 0; i < sorted.length; i++) {
- if (i > 0) {
- sorted[i] = ", " + sorted[i];
- }
- }
- if (more > 0) {
- sorted.push(" & " + more + " more");
- }
- return sorted;
- } }, { key: "stopProp", value: function stopProp(
- e) {
- if (e && e.nativeEvent) {
- e.nativeEvent.preventDefault();
- e.nativeEvent.stopPropagation();
- }
- if (e && e.preventDefault) {
- e.preventDefault();
- e.stopPropagation();
- }
- } }]);return Window;}(React.Component);
\ No newline at end of file
diff --git a/outlib/background.js b/outlib/background.js
deleted file mode 100644
index f1aa36b7..00000000
--- a/outlib/background.js
+++ /dev/null
@@ -1,629 +0,0 @@
-"use strict";var createWindowWithTabs = function () {var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(
-
-
-
-
-
- function _callee(tabs, isIncognito) {var pinnedIndex, firstTab, t, i, firstPinned, w, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, oldTabId, oldTab, tabPinned, movedTabs, newTab;return regeneratorRuntime.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:
-
- pinnedIndex = 0;
- firstTab = tabs.shift();
- t = [];
- for (i = 0; i < tabs.length; i++) {
- t.push(tabs[i].id);
- };
-
- firstPinned = firstTab.pinned;_context.next = 8;return (
- browser.windows.create({ tabId: firstTab.id, incognito: !!isIncognito }));case 8:w = _context.sent;if (!
- firstPinned) {_context.next = 13;break;}_context.next = 12;return (
- browser.tabs.update(w.tabs[0].id, { pinned: firstPinned }));case 12:
- pinnedIndex++;case 13:if (!(
-
-
- t.length > 0)) {_context.next = 60;break;}
- i = 0;_iteratorNormalCompletion2 = true;_didIteratorError2 = false;_iteratorError2 = undefined;_context.prev = 18;_iterator2 =
- t[Symbol.iterator]();case 20:if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) {_context.next = 45;break;}oldTabId = _step2.value;
- i++;_context.next = 25;return (
- browser.tabs.get(oldTabId));case 25:oldTab = _context.sent;
- tabPinned = oldTab.pinned;
- movedTabs = [];if (
- tabPinned) {_context.next = 34;break;}_context.next = 31;return (
- browser.tabs.move(oldTabId, { windowId: w.id, index: -1 }));case 31:movedTabs = _context.sent;_context.next = 37;break;case 34:_context.next = 36;return (
-
- browser.tabs.move(oldTabId, { windowId: w.id, index: pinnedIndex++ }));case 36:movedTabs = _context.sent;case 37:if (!(
-
- movedTabs.length > 0)) {_context.next = 42;break;}
- newTab = movedTabs[0];if (!
- tabPinned) {_context.next = 42;break;}_context.next = 42;return (
- browser.tabs.update(newTab.id, { pinned: tabPinned }));case 42:_iteratorNormalCompletion2 = true;_context.next = 20;break;case 45:_context.next = 51;break;case 47:_context.prev = 47;_context.t0 = _context["catch"](18);_didIteratorError2 = true;_iteratorError2 = _context.t0;case 51:_context.prev = 51;_context.prev = 52;if (!_iteratorNormalCompletion2 && _iterator2.return) {_iterator2.return();}case 54:_context.prev = 54;if (!_didIteratorError2) {_context.next = 57;break;}throw _iteratorError2;case 57:return _context.finish(54);case 58:return _context.finish(51);case 59:
-
-
- ;case 60:_context.next = 62;return (
-
- browser.windows.update(w.id, { focused: true }));case 62:case "end":return _context.stop();}}}, _callee, this, [[18, 47, 51, 59], [52,, 54, 58]]);}));return function createWindowWithTabs(_x, _x2) {return _ref.apply(this, arguments);};}();var focusOnTabAndWindow = function () {var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(
-
-
-
-
-
-
-
- function _callee2(tab) {var windowId, tabId;return regeneratorRuntime.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:
- windowId = tab.windowId;
-
- if (!!tab.tabId) {
- tabId = tab.tabId;
- } else {
- tabId = tab.id;
- }
-
- browser.windows.update(windowId, { focused: true }).then(function (tabId, windowId) {
- browser.tabs.update(tabId, { active: true }).then(function (tabId, windowId) {
- tabActiveChanged({ tabId: tabId, windowId: windowId });
- }.bind(this, tabId, windowId));
- }.bind(this, tabId, windowId));case 3:case "end":return _context2.stop();}}}, _callee2, this);}));return function focusOnTabAndWindow(_x3) {return _ref2.apply(this, arguments);};}();var updateTabCount = function () {var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(
-
-
-
-
-
-
-
-
-
-
- function _callee3() {var run, result, count, toRemove, i, t, found, j;return regeneratorRuntime.wrap(function _callee3$(_context3) {while (1) {switch (_context3.prev = _context3.next) {case 0:
- run = true;
- if (localStorageAvailable()) {
- if (typeof localStorage["badge"] === "undefined") localStorage["badge"] = "1";
- if (localStorage["badge"] == "0") run = false;
- }if (!
-
- run) {_context3.next = 18;break;}_context3.next = 5;return (
- browser.tabs.query({}));case 5:result = _context3.sent;
- count = 0;
- if (!!result && !!result.length) {
- count = result.length;
- }_context3.next = 10;return (
- browser.browserAction.setBadgeText({ text: count + "" }));case 10:_context3.next = 12;return (
- browser.browserAction.setBadgeBackgroundColor({ color: "purple" }));case 12:
- toRemove = [];
- if (!!window.tabsActive) {
- for (i = 0; i < window.tabsActive.length; i++) {
- t = window.tabsActive[i];
- found = false;
- if (!!result && !!result.length) {
- for (j = 0; j < result.length; j++) {
- if (result[j].id == t.tabId) found = true;
- };
- }
- if (!found) toRemove.push(i);
- };
- }
- // console.log("to remove", toRemove);
- for (i = toRemove.length - 1; i >= 0; i--) {
- // console.log("removing", toRemove[i]);
- if (!!window.tabsActive && window.tabsActive.length > 0) {
- if (!!window.tabsActive[toRemove[i]]) window.tabsActive.splice(toRemove[i], 1);
- }
- };_context3.next = 20;break;case 18:_context3.next = 20;return (
-
- browser.browserAction.setBadgeText({ text: "" }));case 20:case "end":return _context3.stop();}}}, _callee3, this);}));return function updateTabCount() {return _ref3.apply(this, arguments);};}();var tabAdded = function () {var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(
-
-
-
-
-
-
-
-
-
- function _callee4(tab) {var tabLimit, tabCount;return regeneratorRuntime.wrap(function _callee4$(_context4) {while (1) {switch (_context4.prev = _context4.next) {case 0:
- if (typeof localStorage["tabLimit"] === "undefined") localStorage["tabLimit"] = "0";
- try {
- tabLimit = JSON.parse(localStorage["tabLimit"]);
- } catch (e) {
- tabLimit = 0;
- }if (!(
- tabLimit > 0)) {_context4.next = 10;break;}if (!(
- tab.id != browser.tabs.TAB_ID_NONE)) {_context4.next = 10;break;}_context4.next = 6;return (
- browser.tabs.query({ currentWindow: true }));case 6:tabCount = _context4.sent;if (!(
- tabCount.length > tabLimit)) {_context4.next = 10;break;}_context4.next = 10;return (
- createWindowWithTabs([tab], tab.incognito));case 10:
-
-
-
- updateTabCountDebounce();case 11:case "end":return _context4.stop();}}}, _callee4, this);}));return function tabAdded(_x4) {return _ref4.apply(this, arguments);};}();var openSidebar = function () {var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function _callee5() {return regeneratorRuntime.wrap(function _callee5$(_context5) {while (1) {switch (_context5.prev = _context5.next) {case 0:_context5.next = 2;return (
- browser.sidebarAction.open());case 2:case "end":return _context5.stop();}}}, _callee5, this);}));return function openSidebar() {return _ref5.apply(this, arguments);};}();var openPopup = function () {var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(
-
-
- function _callee6() {var openInOwnTab;return regeneratorRuntime.wrap(function _callee6$(_context6) {while (1) {switch (_context6.prev = _context6.next) {case 0:
- if (typeof localStorage["openInOwnTab"] === "undefined") localStorage["openInOwnTab"] = "0";
- openInOwnTab = false;
- try {
- openInOwnTab = !!JSON.parse(localStorage["openInOwnTab"]);
- } catch (e) {
- openInOwnTab = false;
- }if (!
- openInOwnTab) {_context6.next = 12;break;}_context6.next = 6;return (
- browser.browserAction.setPopup({ popup: "popup.html?popup=true" }));case 6:_context6.next = 8;return (
- browser.browserAction.openPopup());case 8:_context6.next = 10;return (
- browser.browserAction.setPopup({ popup: "" }));case 10:_context6.next = 14;break;case 12:_context6.next = 14;return (
-
- browser.browserAction.openPopup());case 14:case "end":return _context6.stop();}}}, _callee6, this);}));return function openPopup() {return _ref6.apply(this, arguments);};}();var openAsOwnTab = function () {var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(
-
-
-
- function _callee7() {var popup_page, tabs, currentTab, previousTab, i, tab;return regeneratorRuntime.wrap(function _callee7$(_context7) {while (1) {switch (_context7.prev = _context7.next) {case 0:
- popup_page = browser.runtime.getURL("popup.html");_context7.next = 3;return (
- browser.tabs.query({}));case 3:tabs = _context7.sent;
-
-
-
- if (!!window.tabsActive && window.tabsActive.length > 1) {
- currentTab = window.tabsActive[window.tabsActive.length - 1];
- previousTab = window.tabsActive[window.tabsActive.length - 2];
- }
-
- i = 0;case 6:if (!(i < tabs.length)) {_context7.next = 17;break;}
- tab = tabs[i];if (!(
- tab.url.indexOf("popup.html") > -1 && tab.url.indexOf(popup_page) > -1)) {_context7.next = 14;break;}if (!(
- currentTab && currentTab.tabId && tab.id == currentTab.tabId && previousTab && previousTab.tabId)) {_context7.next = 13;break;}return _context7.abrupt("return",
- focusOnTabAndWindow(previousTab));case 13:return _context7.abrupt("return",
-
- browser.windows.update(tab.windowId, { focused: true }).then(
- function () {
- browser.tabs.highlight({ windowId: tab.windowId, tabs: tab.index });
- }.bind(this)));case 14:i++;_context7.next = 6;break;case 17:return _context7.abrupt("return",
-
-
-
-
- browser.tabs.create({ url: "popup.html" }));case 18:case "end":return _context7.stop();}}}, _callee7, this);}));return function openAsOwnTab() {return _ref7.apply(this, arguments);};}();var setupPopup = function () {var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(
-
-
- function _callee8() {var openInOwnTab;return regeneratorRuntime.wrap(function _callee8$(_context8) {while (1) {switch (_context8.prev = _context8.next) {case 0:
- if (typeof localStorage["openInOwnTab"] === "undefined") localStorage["openInOwnTab"] = "0";
- openInOwnTab = false;
- try {
- openInOwnTab = !!JSON.parse(localStorage["openInOwnTab"]);
- } catch (e) {
- openInOwnTab = false;
- }
- console.log(openInOwnTab);_context8.next = 6;return (
- browser.browserAction.onClicked.removeListener(openAsOwnTab));case 6:if (!
- openInOwnTab) {_context8.next = 13;break;}_context8.next = 9;return (
- browser.browserAction.setPopup({ popup: "" }));case 9:_context8.next = 11;return (
- browser.browserAction.onClicked.addListener(openAsOwnTab));case 11:_context8.next = 15;break;case 13:_context8.next = 15;return (
-
- browser.browserAction.setPopup({ popup: "popup.html?popup=true" }));case 15:
-
- if (browser.sidebarAction) {
- browser.sidebarAction.setPanel({ panel: "popup.html?panel=true" });
- }case 16:case "end":return _context8.stop();}}}, _callee8, this);}));return function setupPopup() {return _ref8.apply(this, arguments);};}();var setupListeners = function () {var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(
-
-
- function _callee9() {return regeneratorRuntime.wrap(function _callee9$(_context9) {while (1) {switch (_context9.prev = _context9.next) {case 0:_context9.next = 2;return (
-
- browser.contextMenus.removeAll());case 2:
- browser.contextMenus.create({
- title: "📔 Open in own tab",
- contexts: ["browser_action"],
- onclick: openAsOwnTab });
-
- if (!!browser.browserAction.openPopup) {
- browser.contextMenus.create({
- title: "📑 Open popup",
- contexts: ["browser_action"],
- onclick: openPopup });
- }
-
- if (!!browser.sidebarAction) {
- browser.contextMenus.create({
- title: "🗂 Open sidebar",
- contexts: ["browser_action"],
- onclick: openSidebar });
- }
-
- browser.contextMenus.create({
- type: "separator",
- contexts: ["browser_action"] });
-
- browser.contextMenus.create({
- title: "😍 Support this extension",
- id: "support_menu",
- "contexts": ["browser_action"] });
-
-
- browser.contextMenus.create({
- title: "⭐ Leave a review",
- "contexts": ["browser_action"],
- parentId: "support_menu",
- onclick: function onclick(info, tab) {
- if (navigator.userAgent.search("Firefox") > -1) {
- browser.tabs.create({ url: 'https://addons.mozilla.org/en-US/firefox/addon/tab-manager-plus-for-firefox/' });
- } else {
- browser.tabs.create({ url: 'https://chrome.google.com/webstore/detail/tab-manager-plus-for-chro/cnkdjjdmfiffagllbiiilooaoofcoeff' });
- }
- } });
-
- browser.contextMenus.create({
- title: "☕ Donate to keep Extensions Alive",
- "contexts": ["browser_action"],
- parentId: "support_menu",
- onclick: function onclick(info, tab) {
- browser.tabs.create({ url: 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=67TZLSEGYQFFW' });
- } });
-
- browser.contextMenus.create({
- title: "💰 Become a Patron",
- "contexts": ["browser_action"],
- parentId: "support_menu",
- onclick: function onclick(info, tab) {
- browser.tabs.create({ url: 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=67TZLSEGYQFFW' });
- } });
-
- browser.contextMenus.create({
- title: "🐦 Follow on Twitter",
- "contexts": ["browser_action"],
- parentId: "support_menu",
- onclick: function onclick(info, tab) {
- browser.tabs.create({ url: 'https://www.twitter.com/mastef' });
- } });
-
- browser.contextMenus.create({
- title: "🤔 Issues and Suggestions",
- id: "code_menu",
- "contexts": ["browser_action"] });
-
-
- browser.contextMenus.create({
- title: "🆕 View recent changes",
- "contexts": ["browser_action"],
- parentId: "code_menu",
- onclick: function onclick(info, tab) {
- browser.tabs.create({ url: 'changelog.html' });
- } });
-
- browser.contextMenus.create({
- title: "⚙ Edit Options",
- "contexts": ["browser_action"],
- parentId: "code_menu",
- onclick: function onclick(info, tab) {
- browser.tabs.create({ url: 'options.html' });
- } });
-
- browser.contextMenus.create({
- title: "💻 View source code",
- "contexts": ["browser_action"],
- parentId: "code_menu",
- onclick: function onclick(info, tab) {
- browser.tabs.create({ url: 'https://github.com/stefanXO/Tab-Manager-Plus' });
- } });
-
- browser.contextMenus.create({
- title: "🤔 Report an issue",
- "contexts": ["browser_action"],
- parentId: "code_menu",
- onclick: function onclick(info, tab) {
- browser.tabs.create({ url: 'https://github.com/stefanXO/Tab-Manager-Plus/issues' });
- } });
-
- browser.contextMenus.create({
- title: "💡 Send a suggestion",
- "contexts": ["browser_action"],
- parentId: "code_menu",
- onclick: function onclick(info, tab) {
- browser.tabs.create({ url: 'https://github.com/stefanXO/Tab-Manager-Plus/issues' });
- browser.tabs.create({ url: 'mailto:markus+tmp@stefanxo.com' });
- } });
-
- setupPopup();
-
- browser.tabs.onCreated.removeListener(tabAdded);
- browser.tabs.onUpdated.removeListener(tabRemoved);
- browser.tabs.onRemoved.removeListener(tabRemoved);
- browser.tabs.onReplaced.removeListener(tabRemoved);
- browser.tabs.onDetached.removeListener(tabRemoved);
- browser.tabs.onAttached.removeListener(tabRemoved);
- browser.tabs.onActivated.removeListener(tabActiveChanged);
- browser.tabs.onMoved.removeListener(tabRemoved);
- browser.windows.onFocusChanged.removeListener(windowFocus);
- browser.windows.onCreated.removeListener(windowCreated);
- browser.windows.onRemoved.removeListener(windowRemoved);
-
- browser.tabs.onCreated.addListener(tabAdded);
- browser.tabs.onUpdated.addListener(tabRemoved);
- browser.tabs.onRemoved.addListener(tabRemoved);
- browser.tabs.onReplaced.addListener(tabRemoved);
- browser.tabs.onDetached.addListener(tabRemoved);
- browser.tabs.onAttached.addListener(tabRemoved);
- browser.tabs.onActivated.addListener(tabActiveChanged);
- browser.tabs.onMoved.addListener(tabRemoved);
- browser.windows.onFocusChanged.addListener(windowFocus);
- browser.windows.onCreated.addListener(windowCreated);
- browser.windows.onRemoved.addListener(windowRemoved);
- updateTabCountDebounce();
-
- setTimeout(cleanUp, 5000);case 42:case "end":return _context9.stop();}}}, _callee9, this);}));return function setupListeners() {return _ref9.apply(this, arguments);};}();
-
-
-// Returns a function, that, as long as it continues to be invoked, will not
-// be triggered. The function will be called after it stops being called for
-// N milliseconds. If `immediate` is passed, trigger the function on the
-// leading edge, instead of the trailing.
-var hideWindows = function () {var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function _callee11(windowId) {var result;return regeneratorRuntime.wrap(function _callee11$(_context11) {while (1) {switch (_context11.prev = _context11.next) {case 0:if (!(
- navigator.userAgent.search("Firefox") > -1)) {_context11.next = 2;break;}return _context11.abrupt("return");case 2:if (!(
-
-
-
- !windowId || windowId < 0)) {_context11.next = 6;break;}return _context11.abrupt("return");case 6:if (!
-
-
- localStorageAvailable()) {_context11.next = 12;break;}
- if (typeof localStorage["hideWindows"] === "undefined") localStorage["hideWindows"] = "0";if (!(
- localStorage["hideWindows"] == "0")) {_context11.next = 10;break;}return _context11.abrupt("return");case 10:_context11.next = 14;break;case 12:
-
- console.log("no local storage");return _context11.abrupt("return");case 14:_context11.next = 16;return (
-
-
-
- browser.permissions.contains({ permissions: ['system.display'] }));case 16:result = _context11.sent;
- if (result) {
- // The extension has the permissions.
- chrome.system.display.getInfo(function () {var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(windowId, displaylayouts) {var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, displaylayout, windows, monitor, i, a, result;return regeneratorRuntime.wrap(function _callee10$(_context10) {while (1) {switch (_context10.prev = _context10.next) {case 0:
- window.displayInfo = [];
- _iteratorNormalCompletion = true;
- _didIteratorError = false;
- _iteratorError = undefined;_context10.prev = 4;
-
- for (_iterator = displaylayouts[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {displaylayout = _step.value;
- window.displayInfo.push(displaylayout.bounds);
- }_context10.next = 12;break;case 8:_context10.prev = 8;_context10.t0 = _context10["catch"](4);
-
- _didIteratorError = true;
- _iteratorError = _context10.t0;case 12:_context10.prev = 12;_context10.prev = 13;
-
-
- if (!_iteratorNormalCompletion && _iterator.return) {
- _iterator.return();
- }case 15:_context10.prev = 15;if (!
-
- _didIteratorError) {_context10.next = 18;break;}throw (
- _iteratorError);case 18:return _context10.finish(15);case 19:return _context10.finish(12);case 20:_context10.next = 22;return (
-
-
-
- browser.windows.getAll({ populate: true }));case 22:windows = _context10.sent;
- monitor = -1;
- for (i = windows.length - 1; i >= 0; i--) {
- if (windows[i].id == windowId) {
- for (a in window.displayInfo) {
- result = is_in_bounds(windows[i], window.displayInfo[a]);
- if (result) {
- monitor = a;
- }
- }
- }
- };
-
- i = windows.length - 1;case 27:if (!(i >= 0)) {_context10.next = 35;break;}if (!(
- windows[i].id != windowId)) {_context10.next = 32;break;}if (!
- is_in_bounds(windows[i], window.displayInfo[monitor])) {_context10.next = 32;break;}_context10.next = 32;return (
- browser.windows.update(windows[i].id, { "state": "minimized" }));case 32:i--;_context10.next = 27;break;case 35:
-
-
- ;case 36:case "end":return _context10.stop();}}}, _callee10, this, [[4, 8, 12, 20], [13,, 15, 19]]);}));return function (_x6, _x7) {return _ref11.apply(this, arguments);};}().
- bind(null, windowId));
- }case 18:case "end":return _context11.stop();}}}, _callee11, this);}));return function hideWindows(_x5) {return _ref10.apply(this, arguments);};}();var cleanUp = function () {var _ref13 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function _callee13() {var activewindows, windowids, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, w, windows, i, names, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, id;return regeneratorRuntime.wrap(function _callee13$(_context13) {while (1) {switch (_context13.prev = _context13.next) {case 0:_context13.next = 2;return (
- browser.windows.getAll({ populate: true }));case 2:activewindows = _context13.sent;
- windowids = [];_iteratorNormalCompletion3 = true;_didIteratorError3 = false;_iteratorError3 = undefined;_context13.prev = 7;
- for (_iterator3 = activewindows[Symbol.iterator](); !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {w = _step3.value;
- windowids.push(w.id);
- }
- // console.log("window ids...", windowids);
- _context13.next = 15;break;case 11:_context13.prev = 11;_context13.t0 = _context13["catch"](7);_didIteratorError3 = true;_iteratorError3 = _context13.t0;case 15:_context13.prev = 15;_context13.prev = 16;if (!_iteratorNormalCompletion3 && _iterator3.return) {_iterator3.return();}case 18:_context13.prev = 18;if (!_didIteratorError3) {_context13.next = 21;break;}throw _iteratorError3;case 21:return _context13.finish(18);case 22:return _context13.finish(15);case 23:windows = JSON.parse(localStorage["windowAge"]);
- if (windows instanceof Array) {
-
- } else {
- windows = [];
- }
- // console.log("before", JSON.parse(JSON.stringify(windows)));
- for (i = windows.length - 1; i >= 0; i--) {
- if (windowids.indexOf(windows[i]) < 0) {
- // console.log("did not find", windows[i], i);
- windows.splice(i, 1);
- }
- };
- // console.log("after", JSON.parse(JSON.stringify(windows)));
- localStorage["windowAge"] = JSON.stringify(windows);
-
- names = localStorage["windowNames"];
- if (!!names) {
- names = JSON.parse(names);
- } else {
- names = {};
- }
-
- // console.log("before", JSON.parse(JSON.stringify(names)));
- _iteratorNormalCompletion4 = true;_didIteratorError4 = false;_iteratorError4 = undefined;_context13.prev = 33;for (_iterator4 = Object.keys(names)[Symbol.iterator](); !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {id = _step4.value;
- if (windowids.indexOf(parseInt(id)) < 0) {
- // console.log("did not find", id);
- delete names[id];
- }
- }
- // console.log("after", JSON.parse(JSON.stringify(names)));
- _context13.next = 41;break;case 37:_context13.prev = 37;_context13.t1 = _context13["catch"](33);_didIteratorError4 = true;_iteratorError4 = _context13.t1;case 41:_context13.prev = 41;_context13.prev = 42;if (!_iteratorNormalCompletion4 && _iterator4.return) {_iterator4.return();}case 44:_context13.prev = 44;if (!_didIteratorError4) {_context13.next = 47;break;}throw _iteratorError4;case 47:return _context13.finish(44);case 48:return _context13.finish(41);case 49:localStorage["windowNames"] = JSON.stringify(names);case 50:case "end":return _context13.stop();}}}, _callee13, this, [[7, 11, 15, 23], [16,, 18, 22], [33, 37, 41, 49], [42,, 44, 48]]);}));return function cleanUp() {return _ref13.apply(this, arguments);};}();function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};}var browser = browser || chrome;window.tabsActive = [];window.displayInfo = [];function focusOnTabAndWindowDelayed(tab) {var tab = JSON.parse(JSON.stringify(tab));setTimeout(focusOnTabAndWindow.bind(this, tab), 125);}function focusOnWindowDelayed(windowId) {setTimeout(focusOnWindow.bind(this, windowId), 125);}function focusOnWindow(windowId) {browser.windows.update(windowId, { focused: true });}var updateTabCountDebounce = debounce(updateTabCount, 250);function tabRemoved() {updateTabCountDebounce();}function tabActiveChanged(tab) {if (!!tab && !!tab.tabId) {if (!window.tabsActive) window.tabsActive = [];if (!!window.tabsActive && window.tabsActive.length > 0) {var lastActive = window.tabsActive[window.tabsActive.length - 1];if (!!lastActive && lastActive.tabId == tab.tabId && lastActive.windowId == tab.windowId) {return;}}while (window.tabsActive.length > 20) {window.tabsActive.shift();}for (var i = window.tabsActive.length - 1; i >= 0; i--) {if (window.tabsActive[i].tabId == tab.tabId) {window.tabsActive.splice(i, 1);}};window.tabsActive.push(tab);}updateTabCountDebounce();}function debounce(func, wait, immediate) {var timeout;return function () {var context = this,args = arguments;var later = function later() {timeout = null;if (!immediate) func.apply(context, args);};var callNow = immediate && !timeout;clearTimeout(timeout);timeout = setTimeout(later, wait);if (callNow) func.apply(context, args);};};function localStorageAvailable() {var test = 'test';try {localStorage.setItem(test, test);localStorage.removeItem(test);return true;} catch (e) {return false;}}function windowFocus(windowId) {try {if (!!windowId) {windowActive(windowId); // console.log("onFocused", windowId);
- hideWindows(windowId);}} catch (e) {}}function windowCreated(window) {try {if (!!window && !!window.id) {windowActive(window.id);}} catch (e) {} // console.log("onCreated", window.id);
-}function windowRemoved(windowId) {try {if (!!windowId) {windowActive(windowId);}} catch (e) {} // console.log("onRemoved", windowId);
-}function is_in_bounds(object, bounds) {var C = object,B = bounds;if (C.left >= B.left && C.left <= B.left + B.width) {if (C.top >= B.top && C.top <= B.top + B.height) {return true;}}return false;};function windowActive(windowId) {if (windowId < 0) return;var windows = JSON.parse(localStorage["windowAge"]);if (windows instanceof Array) {} else {windows = [];}if (windows.indexOf(windowId) > -1) windows.splice(windows.indexOf(windowId), 1);windows.unshift(windowId);localStorage["windowAge"] = JSON.stringify(windows); // browser.windows.getLastFocused({ populate: true }, function (w) {
- // for (var i = 0; i < w.tabs.length; i++) {
- // var tab = w.tabs[i];
- // if (tab.active == true) {
- // // console.log("get last focused", tab.id);
- // // tabActiveChanged({
- // // tabId: tab.id,
- // // windowId: tab.windowId
- // // });
- // }
- // };
- // });
- // console.log(windows);
-}browser.commands.onCommand.addListener(function (command) {if (command == "switch_to_previous_active_tab") {if (!!window.tabsActive && window.tabsActive.length > 1) {focusOnTabAndWindow(window.tabsActive[window.tabsActive.length - 2]);}}});browser.runtime.onMessage.addListener(function (request, sender, sendResponse) {if (request.command == "reload_popup_controls") {setupPopup();}});_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {var windows, i;return regeneratorRuntime.wrap(function _callee12$(_context12) {while (1) {switch (_context12.prev = _context12.next) {case 0:_context12.next = 2;return browser.windows.getAll({ populate: true });case 2:windows = _context12.sent;localStorage["windowAge"] = JSON.stringify([]);if (!!windows && windows.length > 0) {windows.sort(function (a, b) {if (a.id < b.id) return 1;if (a.id > b.id) return -1;return 0;});for (i = 0; i < windows.length; i++) {if (!!windows[i].id) windowActive(windows[i].id);};}case 5:case "end":return _context12.stop();}}}, _callee12, this);}))();setInterval(setupListeners, 300000);setupListeners();
\ No newline at end of file
diff --git a/outlib/changelog.js b/outlib/changelog.js
deleted file mode 100644
index ff78f655..00000000
--- a/outlib/changelog.js
+++ /dev/null
@@ -1 +0,0 @@
-"use strict";window.changelogPage = true;
\ No newline at end of file
diff --git a/outlib/options.js b/outlib/options.js
deleted file mode 100644
index d0c791a6..00000000
--- a/outlib/options.js
+++ /dev/null
@@ -1 +0,0 @@
-"use strict";window.optionPage = true;
\ No newline at end of file
diff --git a/outlib/popup.js b/outlib/popup.js
deleted file mode 100644
index 1515ae0b..00000000
--- a/outlib/popup.js
+++ /dev/null
@@ -1,75 +0,0 @@
-"use strict";
-window.loaded = false;
-if (window.location.search.indexOf("?popup") > -1) {
- window.inPopup = true;
-} else {
- window.inPopup = false;
-}
-if (window.location.search.indexOf("?panel") > -1) {
- window.inPanel = true;
-} else {
- window.inPanel = false;
-}
-window.onload = function () {
- window.requestAnimationFrame(loadApp);
-};
-setTimeout(loadApp, 75);
-setTimeout(loadApp, 125);
-setTimeout(loadApp, 250);
-setTimeout(loadApp, 375);
-setTimeout(loadApp, 700);
-setTimeout(loadApp, 1000);
-setTimeout(loadApp, 2000);
-setTimeout(loadApp, 3000);
-setTimeout(loadApp, 5000);
-setTimeout(loadApp, 15000);
-
-function loadApp() {
- if (!!window.loaded) return;
- if (window.inPopup) {
- if (!!localStorage["tabHeight"]) {
- var height = JSON.parse(localStorage["tabHeight"]);
- document.body.style.height = height + "px";
- }
-
- if (!!localStorage["tabWidth"]) {
- var width = JSON.parse(localStorage["tabWidth"]);
- document.body.style.width = width + "px";
- }
-
- var root = document.getElementById("root");
- if (root != null) {
- var height = document.body.style.height.split("px")[0];
- height = parseInt(height) || 0;
- if (height < 300) {
- height = 400;
- document.body.style.minHeight = height + "px";
- } else {
- height++;
- if (height > 600) height = 600;
- document.body.style.minHeight = height + "px";
- }
- }
- } else {
- if (window.inPanel) {
- document.documentElement.style.maxHeight = "auto";
- document.documentElement.style.maxWidth = "auto";
- document.body.style.maxHeight = "auto";
- document.body.style.maxWidth = "auto";
- }
- document.documentElement.style.maxHeight = "100%";
- document.documentElement.style.maxWidth = "100%";
- document.documentElement.style.height = "100%";
- document.documentElement.style.width = "100%";
- document.body.style.maxHeight = "100%";
- document.body.style.maxWidth = "100%";
- document.body.style.height = "100%";
- document.body.style.width = "100%";
- }
-
- if (!!window.loaded) return;
- window.loaded = true;
- ReactDOM.render(React.createElement(TabManager, { optionsActive: !!window.optionPage }), document.getElementById("TMP"));
-}
-
-window.addEventListener("contextmenu", function (e) {e.preventDefault();});
\ No newline at end of file
diff --git a/package.json b/package.json
index 2ccca7ac..c990d8b0 100644
--- a/package.json
+++ b/package.json
@@ -33,5 +33,6 @@
"babel-preset-react-app": "^3.1.2"
},
"dependencies": {
+ "@webcomponents/custom-elements": "^1.5.1"
}
}
diff --git a/popup.html b/popup.html
index 2601ad00..2069ecfb 100644
--- a/popup.html
+++ b/popup.html
@@ -21,6 +21,7 @@
+