1
0
Эх сурвалжийг харах

fix(GM_openInTab): support insert option as in Tampermonkey

close #579
Gerald 6 жил өмнө
parent
commit
1d911bffd7

+ 11 - 2
src/background/utils/tabs.js

@@ -16,16 +16,25 @@ browser.tabs.onRemoved.addListener((id) => {
 });
 
 export function tabOpen(data, src) {
-  const { url, active } = data;
+  const {
+    url,
+    active,
+    insert = true,
+  } = data;
   const srcTab = src.tab || {};
   const options = {
     url,
     active,
     windowId: srcTab.windowId,
-    index: srcTab.index + 1,
   };
+  if (insert) {
+    options.index = srcTab.index + 1;
+  }
   // Firefox Android does not support `openerTabId` field, it fails if this field is passed
   if (!isFirefox || !isAndroid) {
+    // XXX openerTabId seems buggy on Chrome
+    // It seems to do nothing even set successfully with `browser.tabs.update`.
+    // Reference: http://crbug.com/967150
     options.openerTabId = srcTab.id;
   }
   return browser.tabs.create(options)