xiaoxiaoflood / firefox-scripts

userChromeJS / autoconfig.js and extensions
Mozilla Public License 2.0
944 stars 83 forks source link

Incompatibility between Tab Mix Plus and privateTab.uc.js #175

Closed onemen closed 1 year ago

onemen commented 1 year ago

When PlacesUIUtils.openTabset and PlacesUIUtils._openNodeIn are called when both Tab Mix Plus and privateTab.uc.js installed there are errors

   Uncaught ReferenceError: PrivateBrowsingUtils is not defined
    openTabset chrome://tabmix-resource/content/Places.jsm line 88 > eval:9
    openMultipleLinksInTabs resource:///modules/PlacesUIUtils.sys.mjs:1037
    oncommand chrome://browser/content/browser.xhtml:1
    Uncaught ReferenceError: PlacesUtils is not defined
    PUIU__openNodeIn chrome://tabmix-resource/content/Places.jsm line 88 > eval:15
    PUIU_openNodeWithEvent chrome://tabmix-resource/content/Places.jsm line 88 > eval:16
    BEH_onCommand chrome://browser/content/browser-places.js:880
    oncommand chrome://browser/content/browser.xhtml:1

This is simple fix to this issue

diff --git a/privateTab.uc.js b/privateTab.uc.js
index 5271a4a..31d9567 100644
--- a/privateTab.uc.js
+++ b/privateTab.uc.js
@@ -22,6 +22,12 @@ const {
   PrivateBrowsingUtils
 } = window;

+const lazy = {
+  PlacesUIUtils,
+  PlacesUtils,
+  PrivateBrowsingUtils,
+}
+
 UC.privateTab = {
   config: {
     neverClearData: false, // if you want to not record history but don't care about other data, maybe even want to keep private logins
@@ -299,11 +305,7 @@ UC.privateTab = {
     let { getBrowserWindow } = Cu.import('resource:///modules/PlacesUIUtils.jsm');
     eval('PlacesUIUtils.openTabset = function ' +
           PlacesUIUtils.openTabset.toString().replace(/(\s+)(inBackground: loadInBackground,)/,
-                                                      '$1$2$1userContextId: aEvent.userContextId || 0,')
-                                             .replace(/\blazy\./g, ''));
-
-    eval('PlacesUIUtils._openNodeIn = ' +
-          PlacesUIUtils._openNodeIn.toString().replace(/\blazy\./g, ''));
+                                                      '$1$2$1userContextId: aEvent.userContextId || 0,'));

     let { UUIDMap } = Cu.import('resource://gre/modules/Extension.jsm');
     let TST_ID = 'treestyletab@piro.sakura.ne.jp';
xiaoxiaoflood commented 1 year ago

Thanks. Please check if it's fixed.

onemen commented 1 year ago

Thanks @xiaoxiaoflood

look good to me