Skip to content

Commit

Permalink
switched to browser api and 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mastef committed Aug 5, 2019
1 parent 764ddef commit 10f73cf
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 82 deletions.
4 changes: 2 additions & 2 deletions lib/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
e.preventDefault();
this.props.select(this.props.tab.id);
} else {
chrome.tabs.update(this.props.tab.id, { active: true });
chrome.windows.update(this.props.window.id, { focused: true });
browser.tabs.update(this.props.tab.id, { active: true });
browser.windows.update(this.props.window.id, { focused: true });
}
return false;
},
Expand Down
56 changes: 28 additions & 28 deletions lib/TabManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
if (navigator.userAgent.search("Firefox") > -1) {

} else {
chrome.permissions.contains({
browser.permissions.contains({
permissions: ['system.display'] },
function (result) {
if (result) {
Expand Down Expand Up @@ -41,7 +41,7 @@
if (typeof localStorage["badge"] === "undefined") localStorage["badge"] = "1";
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"] = "4.9.9";
if (typeof localStorage["version"] === "undefined") localStorage["version"] = "5.0.0";

layout = localStorage["layout"];
tabLimit = JSON.parse(localStorage["tabLimit"]);
Expand Down Expand Up @@ -240,14 +240,14 @@

},
componentDidMount: function componentDidMount() {
chrome.windows.onCreated.addListener(this.update.bind(this));
chrome.windows.onRemoved.addListener(this.update.bind(this));
chrome.tabs.onCreated.addListener(this.update.bind(this));
chrome.tabs.onUpdated.addListener(this.update.bind(this));
chrome.tabs.onMoved.addListener(this.update.bind(this));
chrome.tabs.onDetached.addListener(this.update.bind(this));
chrome.tabs.onRemoved.addListener(this.update.bind(this));
chrome.tabs.onReplaced.addListener(this.update.bind(this));
browser.windows.onCreated.addListener(this.update.bind(this));
browser.windows.onRemoved.addListener(this.update.bind(this));
browser.tabs.onCreated.addListener(this.update.bind(this));
browser.tabs.onUpdated.addListener(this.update.bind(this));
browser.tabs.onMoved.addListener(this.update.bind(this));
browser.tabs.onDetached.addListener(this.update.bind(this));
browser.tabs.onRemoved.addListener(this.update.bind(this));
browser.tabs.onReplaced.addListener(this.update.bind(this));
this.refs.root.focus();
this.focusRoot();
setTimeout(function () {
Expand Down Expand Up @@ -344,15 +344,15 @@
this.forceUpdate();
},
rateExtension: function rateExtension() {
chrome.tabs.create({ url: 'https://chrome.google.com/webstore/detail/tab-manager-plus-for-chro/cnkdjjdmfiffagllbiiilooaoofcoeff' });
browser.tabs.create({ url: 'https://chrome.google.com/webstore/detail/tab-manager-plus-for-chro/cnkdjjdmfiffagllbiiilooaoofcoeff' });
this.forceUpdate();
},
toggleOptions: function toggleOptions() {
this.state.optionsActive = !this.state.optionsActive;
this.forceUpdate();
},
update: function update() {
chrome.windows.getAll({ populate: true }, function (windows) {
browser.windows.getAll({ populate: true }, function (windows) {
windows.sort(function (a, b) {
var windows = [];
if (!!localStorage["windowAge"]) {
Expand Down Expand Up @@ -393,32 +393,32 @@
var tabs = Object.keys(this.state.selection).map(function (id) {return _this2.state.tabsbyid[id];});
if (tabs.length) {
for (var i = 0; i < tabs.length; i++) {
chrome.tabs.remove(tabs[i].id);
browser.tabs.remove(tabs[i].id);
}
} else {
chrome.tabs.query({ currentWindow: true, active: true }, function (t) {
browser.tabs.query({ currentWindow: true, active: true }, function (t) {
if (t && t.length > 0) {
chrome.tabs.remove(t[0].id);
browser.tabs.remove(t[0].id);
}
});
}
this.forceUpdate();
},
deleteTab: function deleteTab(tabId) {
chrome.tabs.remove(tabId);
browser.tabs.remove(tabId);
},
addWindow: function addWindow() {var _this3 = this;
var count = Object.keys(this.state.selection).length;
var tabs = Object.keys(this.state.selection).map(function (id) {return _this3.state.tabsbyid[id];});

if (count == 0) {
chrome.windows.create({});
browser.windows.create({});
} else if (count == 1) {
chrome.runtime.getBackgroundPage(function callback(tabs, backgroundPage) {
browser.runtime.getBackgroundPage(function callback(tabs, backgroundPage) {
backgroundPage.focusOnTabAndWindow(tabs[0]);
}.bind(null, tabs));
} else {
chrome.runtime.getBackgroundPage(function callback(tabs, backgroundPage) {
browser.runtime.getBackgroundPage(function callback(tabs, backgroundPage) {
backgroundPage.createWindowWithTabs(tabs);
}.bind(null, tabs));
}
Expand All @@ -428,13 +428,13 @@
if (tabs.length) {
if (tabs[0].pinned) tabs.reverse();
for (var i = 0; i < tabs.length; i++) {
chrome.tabs.update(tabs[i].id, { pinned: !tabs[0].pinned });
browser.tabs.update(tabs[i].id, { pinned: !tabs[0].pinned });
}

} else {
chrome.tabs.query({ currentWindow: true, active: true }, function (t) {
browser.tabs.query({ currentWindow: true, active: true }, function (t) {
if (t && t.length > 0) {
chrome.tabs.update(t[0].id, { pinned: !t[0].pinned });
browser.tabs.update(t[0].id, { pinned: !t[0].pinned });
}
});
}
Expand Down Expand Up @@ -652,8 +652,8 @@

for (var i = 0; i < tabs.length; i++) {
(function (t) {
chrome.tabs.move(t.id, { windowId: tab.windowId, index: index }, function () {
chrome.tabs.update(t.id, { pinned: t.pinned });
browser.tabs.move(t.id, { windowId: tab.windowId, index: index }, function () {
browser.tabs.update(t.id, { pinned: t.pinned });
});
})(tabs[i]);
}
Expand All @@ -663,8 +663,8 @@
var tabs = Object.keys(this.state.selection).map(function (id) {return _this6.state.tabsbyid[id];});
for (var i = 0; i < tabs.length; i++) {
(function (t, windowId) {
chrome.tabs.move(t.id, { windowId: windowId, index: -1 }, function () {
chrome.tabs.update(t.id, { pinned: t.pinned });
browser.tabs.move(t.id, { windowId: windowId, index: -1 }, function () {
browser.tabs.update(t.id, { pinned: t.pinned });
});
})(tabs[i], windowId);
}
Expand Down Expand Up @@ -753,7 +753,7 @@
this.state.badge = !this.state.badge;
localStorage["badge"] = this.state.badge ? "1" : "0";
this.badgeText();
chrome.runtime.getBackgroundPage(function callback(backgroundPage) {
browser.runtime.getBackgroundPage(function callback(backgroundPage) {
backgroundPage.updateTabCount();
});
this.forceUpdate();
Expand All @@ -764,7 +764,7 @@

},
toggleHide: function toggleHide() {
chrome.permissions.request({ permissions: ["system.display"] }, function (granted) {
browser.permissions.request({ permissions: ["system.display"] }, function (granted) {
if (granted) {
this.state.hideWindows = !this.state.hideWindows;
} else {
Expand Down
6 changes: 3 additions & 3 deletions lib/TabOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
logo: function logo() {
var logo = [
React.DOM.img({ src: "images/browsers.svg", style: { "max-width": "3rem" } }),
React.DOM.h2({}, "Tab Manager Plus 4.9.9")];
React.DOM.h2({}, "Tab Manager Plus 5.0.0")];

return React.DOM.div({ className: "logo-options" }, React.DOM.div({ className: "logo-box" }, logo));
},
Expand Down Expand Up @@ -193,10 +193,10 @@
return React.DOM.div({ className: "toggle-options" }, opts);
},
openIncognitoOptions: function openIncognitoOptions() {
chrome.tabs.create({ url: 'chrome://extensions/?id=cnkdjjdmfiffagllbiiilooaoofcoeff' });
browser.tabs.create({ url: 'chrome://extensions/?id=cnkdjjdmfiffagllbiiilooaoofcoeff' });
},
openShortcuts: function openShortcuts() {
chrome.tabs.create({ url: 'chrome://extensions/shortcuts' });
browser.tabs.create({ url: 'chrome://extensions/shortcuts' });
},
licenses: function licenses() {
var licenses = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/TabOptionsFirefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
logo: function logo() {
var logo = [
React.DOM.img({ src: "images/browsers.svg", style: { "max-width": "3rem" } }),
React.DOM.h2({}, "Tab Manager Plus 4.9.9")];
React.DOM.h2({}, "Tab Manager Plus 5.0.0")];

return React.DOM.div({ className: "logo-options" }, React.DOM.div({ className: "logo-box" }, logo));
},
Expand Down
10 changes: 5 additions & 5 deletions lib/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
},
addTab: function addTab(e) {
e.stopPropagation();
chrome.tabs.create({ windowId: this.props.window.id });
browser.tabs.create({ windowId: this.props.window.id });
},
dragOver: function dragOver(e) {
e.nativeEvent.preventDefault();
Expand All @@ -193,23 +193,23 @@
this.props.dropWindow(this.props.window.id);
},
windowClick: function windowClick() {
chrome.windows.update(this.props.window.id, {
browser.windows.update(this.props.window.id, {
"focused": true },
function (a) {this.props.parentUpdate();}.bind(this));
},
close: function close(e) {
e.stopPropagation();
chrome.windows.remove(this.props.window.id);
browser.windows.remove(this.props.window.id);
},
minimize: function minimize(e) {
e.stopPropagation();
chrome.windows.update(this.props.window.id, {
browser.windows.update(this.props.window.id, {
"state": "minimized" },
function (a) {this.props.parentUpdate();}.bind(this));
},
maximize: function maximize(e) {
e.stopPropagation();
chrome.windows.update(this.props.window.id, {
browser.windows.update(this.props.window.id, {
"state": "normal" },
function (a) {this.props.parentUpdate();}.bind(this));
},
Expand Down
Loading

0 comments on commit 10f73cf

Please sign in to comment.