Skip to content

Commit 10f73cf

Browse files
committed
switched to browser api and 5.0.0
1 parent 764ddef commit 10f73cf

8 files changed

Lines changed: 82 additions & 82 deletions

File tree

lib/Tab.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
e.preventDefault();
5858
this.props.select(this.props.tab.id);
5959
} else {
60-
chrome.tabs.update(this.props.tab.id, { active: true });
61-
chrome.windows.update(this.props.window.id, { focused: true });
60+
browser.tabs.update(this.props.tab.id, { active: true });
61+
browser.windows.update(this.props.window.id, { focused: true });
6262
}
6363
return false;
6464
},

lib/TabManager.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
if (navigator.userAgent.search("Firefox") > -1) {
66

77
} else {
8-
chrome.permissions.contains({
8+
browser.permissions.contains({
99
permissions: ['system.display'] },
1010
function (result) {
1111
if (result) {
@@ -41,7 +41,7 @@
4141
if (typeof localStorage["badge"] === "undefined") localStorage["badge"] = "1";
4242
if (typeof localStorage["hideWindows"] === "undefined") localStorage["hideWindows"] = "0";
4343
if (typeof localStorage["filter-tabs"] === "undefined") localStorage["filter-tabs"] = "0";
44-
if (typeof localStorage["version"] === "undefined") localStorage["version"] = "4.9.9";
44+
if (typeof localStorage["version"] === "undefined") localStorage["version"] = "5.0.0";
4545

4646
layout = localStorage["layout"];
4747
tabLimit = JSON.parse(localStorage["tabLimit"]);
@@ -240,14 +240,14 @@
240240

241241
},
242242
componentDidMount: function componentDidMount() {
243-
chrome.windows.onCreated.addListener(this.update.bind(this));
244-
chrome.windows.onRemoved.addListener(this.update.bind(this));
245-
chrome.tabs.onCreated.addListener(this.update.bind(this));
246-
chrome.tabs.onUpdated.addListener(this.update.bind(this));
247-
chrome.tabs.onMoved.addListener(this.update.bind(this));
248-
chrome.tabs.onDetached.addListener(this.update.bind(this));
249-
chrome.tabs.onRemoved.addListener(this.update.bind(this));
250-
chrome.tabs.onReplaced.addListener(this.update.bind(this));
243+
browser.windows.onCreated.addListener(this.update.bind(this));
244+
browser.windows.onRemoved.addListener(this.update.bind(this));
245+
browser.tabs.onCreated.addListener(this.update.bind(this));
246+
browser.tabs.onUpdated.addListener(this.update.bind(this));
247+
browser.tabs.onMoved.addListener(this.update.bind(this));
248+
browser.tabs.onDetached.addListener(this.update.bind(this));
249+
browser.tabs.onRemoved.addListener(this.update.bind(this));
250+
browser.tabs.onReplaced.addListener(this.update.bind(this));
251251
this.refs.root.focus();
252252
this.focusRoot();
253253
setTimeout(function () {
@@ -344,15 +344,15 @@
344344
this.forceUpdate();
345345
},
346346
rateExtension: function rateExtension() {
347-
chrome.tabs.create({ url: 'https://chrome.google.com/webstore/detail/tab-manager-plus-for-chro/cnkdjjdmfiffagllbiiilooaoofcoeff' });
347+
browser.tabs.create({ url: 'https://chrome.google.com/webstore/detail/tab-manager-plus-for-chro/cnkdjjdmfiffagllbiiilooaoofcoeff' });
348348
this.forceUpdate();
349349
},
350350
toggleOptions: function toggleOptions() {
351351
this.state.optionsActive = !this.state.optionsActive;
352352
this.forceUpdate();
353353
},
354354
update: function update() {
355-
chrome.windows.getAll({ populate: true }, function (windows) {
355+
browser.windows.getAll({ populate: true }, function (windows) {
356356
windows.sort(function (a, b) {
357357
var windows = [];
358358
if (!!localStorage["windowAge"]) {
@@ -393,32 +393,32 @@
393393
var tabs = Object.keys(this.state.selection).map(function (id) {return _this2.state.tabsbyid[id];});
394394
if (tabs.length) {
395395
for (var i = 0; i < tabs.length; i++) {
396-
chrome.tabs.remove(tabs[i].id);
396+
browser.tabs.remove(tabs[i].id);
397397
}
398398
} else {
399-
chrome.tabs.query({ currentWindow: true, active: true }, function (t) {
399+
browser.tabs.query({ currentWindow: true, active: true }, function (t) {
400400
if (t && t.length > 0) {
401-
chrome.tabs.remove(t[0].id);
401+
browser.tabs.remove(t[0].id);
402402
}
403403
});
404404
}
405405
this.forceUpdate();
406406
},
407407
deleteTab: function deleteTab(tabId) {
408-
chrome.tabs.remove(tabId);
408+
browser.tabs.remove(tabId);
409409
},
410410
addWindow: function addWindow() {var _this3 = this;
411411
var count = Object.keys(this.state.selection).length;
412412
var tabs = Object.keys(this.state.selection).map(function (id) {return _this3.state.tabsbyid[id];});
413413

414414
if (count == 0) {
415-
chrome.windows.create({});
415+
browser.windows.create({});
416416
} else if (count == 1) {
417-
chrome.runtime.getBackgroundPage(function callback(tabs, backgroundPage) {
417+
browser.runtime.getBackgroundPage(function callback(tabs, backgroundPage) {
418418
backgroundPage.focusOnTabAndWindow(tabs[0]);
419419
}.bind(null, tabs));
420420
} else {
421-
chrome.runtime.getBackgroundPage(function callback(tabs, backgroundPage) {
421+
browser.runtime.getBackgroundPage(function callback(tabs, backgroundPage) {
422422
backgroundPage.createWindowWithTabs(tabs);
423423
}.bind(null, tabs));
424424
}
@@ -428,13 +428,13 @@
428428
if (tabs.length) {
429429
if (tabs[0].pinned) tabs.reverse();
430430
for (var i = 0; i < tabs.length; i++) {
431-
chrome.tabs.update(tabs[i].id, { pinned: !tabs[0].pinned });
431+
browser.tabs.update(tabs[i].id, { pinned: !tabs[0].pinned });
432432
}
433433

434434
} else {
435-
chrome.tabs.query({ currentWindow: true, active: true }, function (t) {
435+
browser.tabs.query({ currentWindow: true, active: true }, function (t) {
436436
if (t && t.length > 0) {
437-
chrome.tabs.update(t[0].id, { pinned: !t[0].pinned });
437+
browser.tabs.update(t[0].id, { pinned: !t[0].pinned });
438438
}
439439
});
440440
}
@@ -652,8 +652,8 @@
652652

653653
for (var i = 0; i < tabs.length; i++) {
654654
(function (t) {
655-
chrome.tabs.move(t.id, { windowId: tab.windowId, index: index }, function () {
656-
chrome.tabs.update(t.id, { pinned: t.pinned });
655+
browser.tabs.move(t.id, { windowId: tab.windowId, index: index }, function () {
656+
browser.tabs.update(t.id, { pinned: t.pinned });
657657
});
658658
})(tabs[i]);
659659
}
@@ -663,8 +663,8 @@
663663
var tabs = Object.keys(this.state.selection).map(function (id) {return _this6.state.tabsbyid[id];});
664664
for (var i = 0; i < tabs.length; i++) {
665665
(function (t, windowId) {
666-
chrome.tabs.move(t.id, { windowId: windowId, index: -1 }, function () {
667-
chrome.tabs.update(t.id, { pinned: t.pinned });
666+
browser.tabs.move(t.id, { windowId: windowId, index: -1 }, function () {
667+
browser.tabs.update(t.id, { pinned: t.pinned });
668668
});
669669
})(tabs[i], windowId);
670670
}
@@ -753,7 +753,7 @@
753753
this.state.badge = !this.state.badge;
754754
localStorage["badge"] = this.state.badge ? "1" : "0";
755755
this.badgeText();
756-
chrome.runtime.getBackgroundPage(function callback(backgroundPage) {
756+
browser.runtime.getBackgroundPage(function callback(backgroundPage) {
757757
backgroundPage.updateTabCount();
758758
});
759759
this.forceUpdate();
@@ -764,7 +764,7 @@
764764

765765
},
766766
toggleHide: function toggleHide() {
767-
chrome.permissions.request({ permissions: ["system.display"] }, function (granted) {
767+
browser.permissions.request({ permissions: ["system.display"] }, function (granted) {
768768
if (granted) {
769769
this.state.hideWindows = !this.state.hideWindows;
770770
} else {

lib/TabOptions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
logo: function logo() {
66
var logo = [
77
React.DOM.img({ src: "images/browsers.svg", style: { "max-width": "3rem" } }),
8-
React.DOM.h2({}, "Tab Manager Plus 4.9.9")];
8+
React.DOM.h2({}, "Tab Manager Plus 5.0.0")];
99

1010
return React.DOM.div({ className: "logo-options" }, React.DOM.div({ className: "logo-box" }, logo));
1111
},
@@ -193,10 +193,10 @@
193193
return React.DOM.div({ className: "toggle-options" }, opts);
194194
},
195195
openIncognitoOptions: function openIncognitoOptions() {
196-
chrome.tabs.create({ url: 'chrome://extensions/?id=cnkdjjdmfiffagllbiiilooaoofcoeff' });
196+
browser.tabs.create({ url: 'chrome://extensions/?id=cnkdjjdmfiffagllbiiilooaoofcoeff' });
197197
},
198198
openShortcuts: function openShortcuts() {
199-
chrome.tabs.create({ url: 'chrome://extensions/shortcuts' });
199+
browser.tabs.create({ url: 'chrome://extensions/shortcuts' });
200200
},
201201
licenses: function licenses() {
202202
var licenses = [];

lib/TabOptionsFirefox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
logo: function logo() {
66
var logo = [
77
React.DOM.img({ src: "images/browsers.svg", style: { "max-width": "3rem" } }),
8-
React.DOM.h2({}, "Tab Manager Plus 4.9.9")];
8+
React.DOM.h2({}, "Tab Manager Plus 5.0.0")];
99

1010
return React.DOM.div({ className: "logo-options" }, React.DOM.div({ className: "logo-box" }, logo));
1111
},

lib/Window.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
},
184184
addTab: function addTab(e) {
185185
e.stopPropagation();
186-
chrome.tabs.create({ windowId: this.props.window.id });
186+
browser.tabs.create({ windowId: this.props.window.id });
187187
},
188188
dragOver: function dragOver(e) {
189189
e.nativeEvent.preventDefault();
@@ -193,23 +193,23 @@
193193
this.props.dropWindow(this.props.window.id);
194194
},
195195
windowClick: function windowClick() {
196-
chrome.windows.update(this.props.window.id, {
196+
browser.windows.update(this.props.window.id, {
197197
"focused": true },
198198
function (a) {this.props.parentUpdate();}.bind(this));
199199
},
200200
close: function close(e) {
201201
e.stopPropagation();
202-
chrome.windows.remove(this.props.window.id);
202+
browser.windows.remove(this.props.window.id);
203203
},
204204
minimize: function minimize(e) {
205205
e.stopPropagation();
206-
chrome.windows.update(this.props.window.id, {
206+
browser.windows.update(this.props.window.id, {
207207
"state": "minimized" },
208208
function (a) {this.props.parentUpdate();}.bind(this));
209209
},
210210
maximize: function maximize(e) {
211211
e.stopPropagation();
212-
chrome.windows.update(this.props.window.id, {
212+
browser.windows.update(this.props.window.id, {
213213
"state": "normal" },
214214
function (a) {this.props.parentUpdate();}.bind(this));
215215
},

0 commit comments

Comments
 (0)