[Pkg-mozext-commits] [greasemonkey] 43/62: GM_openInTab: synchronize API with Tampermonkey (backward compatible)
David Prévot
taffit at moszumanska.debian.org
Sun Sep 13 22:10:23 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository greasemonkey.
commit a3ec30452dd359d0c2e1b2246988d813bb1fc3a7
Author: janekptacijarabaci <janekptacijarabaci at seznam.cz>
Date: Mon Aug 24 23:40:27 2015 +0200
GM_openInTab: synchronize API with Tampermonkey (backward compatible)
---
content/browser.js | 15 ++++++++++-----
modules/GM_openInTab.js | 22 +++++++++++++++++++---
2 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/content/browser.js b/content/browser.js
index 3118e87..3e0824d 100644
--- a/content/browser.js
+++ b/content/browser.js
@@ -79,14 +79,19 @@ GM_BrowserUI.openInTab = function(aMessage) {
var getBool = Services.prefs.getBoolPref;
- var prefBg = getBool('browser.tabs.loadInBackground');
- prefBg = (aMessage.data.inBackground === null)
- ? prefBg
+ var prefBg = (aMessage.data.inBackground === null)
+ ? getBool("browser.tabs.loadInBackground")
: aMessage.data.inBackground;
if (scriptTabIsCurrentTab && !prefBg) tabBrowser.selectedTab = newTab;
- var prefRel = getBool('browser.tabs.insertRelatedAfterCurrent');
- if (prefRel) tabBrowser.moveTabTo(newTab, scriptTab._tPos + 1);
+ var prefRel = (aMessage.data.afterCurrent === null)
+ ? getBool("browser.tabs.insertRelatedAfterCurrent")
+ : aMessage.data.afterCurrent;
+ if (prefRel) {
+ tabBrowser.moveTabTo(newTab, scriptTab._tPos + 1);
+ } else {
+ tabBrowser.moveTabTo(newTab, tabBrowser.tabs.length - 1);
+ }
};
/**
diff --git a/modules/GM_openInTab.js b/modules/GM_openInTab.js
index 99585c7..89d8a8b 100644
--- a/modules/GM_openInTab.js
+++ b/modules/GM_openInTab.js
@@ -7,15 +7,31 @@ var Cc = Components.classes;
Cu.import('resource://gre/modules/Services.jsm');
-function GM_openInTab(aFrame, aBaseUrl, aUrl, aInBackground) {
- var loadInBackground = ('undefined' == typeof aInBackground)
- ? null : !!aInBackground;
+function GM_openInTab(aFrame, aBaseUrl, aUrl, aOptions) {
+ var loadInBackground = null;
+ if ("undefined" != typeof aOptions) {
+ if ("undefined" == typeof aOptions.active) {
+ if ("object" != typeof aOptions) {
+ loadInBackground = !!aOptions;
+ }
+ } else {
+ loadInBackground = !aOptions.active;
+ }
+ }
+
+ var insertRelatedAfterCurrent = null;
+ if ("undefined" != typeof aOptions) {
+ if ("undefined" != typeof aOptions.insert) {
+ insertRelatedAfterCurrent = !!aOptions.insert;
+ }
+ }
// Resolve URL relative to the location of the content window.
var baseUri = Services.io.newURI(aBaseUrl, null, null);
var uri = Services.io.newURI(aUrl, null, baseUri);
aFrame.sendAsyncMessage('greasemonkey:open-in-tab', {
+ afterCurrent: insertRelatedAfterCurrent,
inBackground: loadInBackground,
url: uri.spec,
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/greasemonkey.git
More information about the Pkg-mozext-commits
mailing list