Aris-t2 / CustomJSforFx

custom scripts
GNU General Public License v3.0
236 stars 22 forks source link

[JavaScript][Firefox] General JavaScript talk and custom userChrome.js scripts (v2) #29

Closed Aris-t2 closed 2 years ago

Aris-t2 commented 4 years ago

Lets discuss everything related to JavaScript here instead of opening new threads for questions or request.

Continued from https://github.com/Aris-t2/CustomJSforFx/issues/4

Custom scripts https://github.com/Aris-t2/CustomJSforFx/tree/master/scripts

Other custom script collections - by ardiman - by Endor8

allnamesarealreadytaken commented 4 years ago

Yes, that's the one. userChrome.js now contains: // userChrome.js userChrome.ignoreCache = true; // does not always work, so forget this better ;-) //userChrome.import("/userChrome/my_script_name.uc.js", "UChrm"); userChrome.import("/userChrome/alternative_searchbar.uc.js", "UChrm"); alternative_searchbar.uc.js is located in chrome/userChrome directory, with userChromeJS.js and userChromeJSutilities.js

Aris-t2 commented 4 years ago

Just tested everything again in portable Fx, Still works as it should.

Posted a new file to fix label position for show_search_engine_names option on Fx72+.

Pizzapops commented 4 years ago

@Aris-t2 Clarification on Method 2 setup? The main page and zip file infer that the userChrome folder and userChrome.js go in the profile/ folder. I have always put them in profile/Chrome/. Which is correct?

I am working with a Reddit user that is confused and cannot CustomJSforFx to work.

Aris-t2 commented 4 years ago

I guess one could see it like this, if not reading the instructions on the main page.

Pizzapops commented 4 years ago

@Aris-t2 You got me. I haven't looked at the readme for 18+ months.

Latest version Fx updates do not seem to have any big created problems. I only noticed a minor change in Nightly 75 and locationbar_popup_classic_with_two_lined_results.uc.js

2020-02-11_094744

Styling toolbar button tooltips disappeared with Fx72. Is it still possible?

Minor request: Could a middle click option be added to about_button.uc.js ? About Firefox would be nice. Yes, i know it is only 3 clicks on the app menu or Alt H A. I have tried to do it without luck.

Previously, I posted a script for appbutton_movable. I also have a script to make the overflow button movable. overflow-button_movable.uc.zip

Aris-t2 commented 4 years ago

If you want to use locationbar_popup_classic_with_two_lined_results.uc.js on Firefox 73+ make sure about:config > browser.urlbar.update1 is set to false.

If you want to keep browsers default megabar, CustomCSSforFx offers a few new options to (mostly) achieve two lined results based on most recent browser code.

https://github.com/Aris-t2/CustomCSSforFx/blob/master/classic/css/locationbar/megabar_optimizations.css https://github.com/Aris-t2/CustomCSSforFx/blob/master/classic/css/locationbar/ac_popup_megabar_title_and_url_two_lines.css

Tooltip CSS code does not affect the tooltip/tooltiptext node of buttons anymore. Not sure there is a way using CSS to override this.

About button I will look into it.


Other about urls for middle click function (add the code snippet below the other click case if(event.button=='0') {...}):

      if(event.button=='1') {
        try {
          gBrowser.selectedTab = gBrowser.addTrustedTab('about:rights');
        } catch (e) {}
      } 
Pizzapops commented 4 years ago

@Aris-t2 Thanks for the about:config tip.

Common opinion on toolbar tooltips is the same as yours. Several have suggested that it might be possible with javascript but no solid solution offered.

I figured out the event.button=='1' part of adding About Firefox to the About button. Getting the command to open it is the problem. I use Stonecrusher's SimpleMenuWizard to prune popup menus. His main-menubar.css and main-hamburger.css have clues but I haven't been able to incorporate either of them.

Hamburger: #PanelUI-helpView [oncommand*="openAboutDialog()"] Top Menu: #aboutName

Side question: Should xml files in scripts be changed to xhtml (ie password manager)?

Aris-t2 commented 4 years ago

You are looking for this:

  if(event.button=='1') {
    try {
      openAboutDialog();
    } catch (e) {}
  } 

Full file would be this:

// 'about:'-Button script for Firefox 60+ by Aris
//
// Need a different 'about' page button?
// - replace 'about:config' url with a different 'about:' url
// - replace button id
// - replace icon / icon url / icon color

(function() {

try {
  Components.utils.import("resource:///modules/CustomizableUI.jsm");
  var {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {});
  var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);

  var button_label = "About Button";

  CustomizableUI.createWidget({
    id: "about-button", // button id
    defaultArea: CustomizableUI.AREA_NAVBAR,
    removable: true,
    label: button_label, // button title
    tooltiptext: button_label, // tooltip title
    onClick: function(event) {
      if(event.button=='0') {
        try {
          gBrowser.selectedTab = gBrowser.addTrustedTab('about:config');
        } catch (e) {}
      } 

      if(event.button=='1') {
        try {
          openAboutDialog();
        } catch (e) {}
      } 

    },
    onCreated: function(button) {
      return button;
    }

  });

  // style button icon
  var uri = Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent('\
    \
      #about-button .toolbarbutton-icon {\
        list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.svg"); /* icon / path to icon */ \
        fill: blue; /* icon color name/code */\
      }\
    \
  '), null, null);

  sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);

} catch (e) {
    Components.utils.reportError(e);
};

})();
Pizzapops commented 4 years ago

@Aris-t2 Thanks for the quick reply. About Button is working as desired.

BoomerangAide commented 4 years ago

For the latest (70+ maybe) versions, in password_manager_button.uc.js, would opening "about:logins" instead of the xul thing be an improvement?

Aris-t2 commented 4 years ago

password_manager_button.uc.js and password_manager_button_v2.uc.js both offer the old and the new password manager. Left-click and middle-click function are swapped between default and the v2 one, so that one is most likely what you are looking for.

Pizzapops commented 4 years ago

Old password manager is not working for 73-75. I get a "Problem loading page" error message. It does work for 72, ESR, Tor & Waterfox Current. Trying to load chrome://passwordmgr/content/passwordManager.xul gives "File not found" screen.

Acid-Crash commented 4 years ago

@Pizzapops Guess the link was replaced with chrome://passwordmgr/content/passwordManager.xhtml Not sure if it is fully functional though

Pizzapops commented 4 years ago

@Acid-Crash That was my question 3 days ago.

Yes, .xhtml version does work. I will put changed scripts, password_manager_button_73.uc.js and password_manager_button_73v2.uc.js, in 73-75 and check functionality.

Aris-t2 commented 4 years ago

I merged v1 and v2 and fixed the Fx 73+ issue. Thanks for the tip (xul > xhtml). password_manager_button.uc.js https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/password_manager_button.uc.js

Acid-Crash commented 4 years ago

Hi @Aris-t2 I have noticed that you have hardcoded dimension for the window. At some point I've manager to make that window resizable (IIRC with resizable=yes). Unfortunately can't find that piece of the code...

Aris-t2 commented 4 years ago

Setting own/other/custom dimension values won't change window size at least in my tests, but setting no dimensions only caption buttons of the window appear.

Acid-Crash commented 4 years ago

@Aris-t2 Looks like I've found the mentioned code piece. Replaced https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/password_manager_button.uc.js#L35 https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/password_manager_button.uc.js#L49 With this the popup window becomes resizable (tested on Win10) window.open(old_pw_manager ,'', 'chrome, resizable', "width=400,height=400");

UPD. Guess it is from here https://developer.mozilla.org/en-US/docs/Web/API/Window/open

Pizzapops commented 4 years ago

Is it possible for the new Password Manager to also open in a resizable popup window? 2/3 of the about:logins page is empty white space. More compacting can come later.

Aris-t2 commented 4 years ago

Try the new solution ;-) https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/password_manager_button.uc.js

Pizzapops commented 4 years ago

@Aris-t2 You are quick! New PW manager pops up empty and on the top left corner of my left monitor (Fx75 on rt monitor).

OFF TOPIC: Any insight or opinion on MrAlex/Waterfox move to SYSTEM1?

Aris-t2 commented 4 years ago

You are right about the pw manager. Looks like loading web sites using window.open is prevented and since about:logins is a web site and not a chrome page, the issue occurs. No idea how to get around this. Edit: I removed the recent changes for now. They can still be found in files history.

I've heard about Waterfox changing owner, but haven't looked into it.

tortious commented 4 years ago

Hey everyone,

I have run into a bit of a problem with an old script and was hoping someone here could help. I already tried posting over at r/firefoxcss, but was unable to get it working despite solid attempts by MrOtherGuy (I'm sure you might recognize the name, as he is a frequenter commenter and has a pretty dope repo of css-related hacks, himself).

Anyway, the script is for a movable page titlebar. It acted exactly like an addon would, in terms of its functionality on the toolbar. Now, unfortunately, it just says "null" regardless of the page I am on.

Here is a link to the reddit thread I posted about it. The advice I suggested did not work and merely removed the entire display from the toolbar (despite it still being visible in "customization" mode and retaining its functionality, in that regard).

Any and all help is greatly appreciated. Thanks, in advance!

The following is Movable-Page-Titlebar.uc.js

// Create a new custom toolbaritem, that has titlebar text displayed on it.
// If you're still not sure what it does check out the below.
// https://imgur.com/sXZrBMb
// https://imgur.com/a/GHvgjzu

(function () {

  if (location != "chrome://browser/content/browser.xul" && location != "chrome://browser/content/browser.xhtml") {
    return;
  }

  try {
    CustomizableUI.createWidget({
      id: "pagetitle-bar",
      type: "custom",
      defaultArea: CustomizableUI.AREA_NAVBAR,
      onBuild: function(aDocument) {
        const toolbaritem = aDocument.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "toolbaritem");
        const image = aDocument.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "image");
        image.setAttribute("src", "chrome://branding/content/icon16.png");
        image.id = "pagetitle-bar-image";
        const props = {
          id: "pagetitle-bar",
          class: "chromeclass-toolbar-additional",
          titlepage: "",
          tooltiptext: "",
          pack: "center",
          align: "center",
          label: "Page Title Bar"
        };
        for (var p in props) {
          toolbaritem.setAttribute(p, props[p]);
        }
        toolbaritem.appendChild(image);
        return toolbaritem;
      }
    });
  } catch(e) {}

  function setPageTitle () {
    if (!document.getElementById("pagetitle-bar")) {
      return;
    }
    const pageTitleBar = document.getElementById("pagetitle-bar");

    let pageTitle = document.title;
    // remove the - Mozilla Firefox *** at the end of the title, comment out the lines below if you don't want it
    const index = pageTitle.lastIndexOf(" - ");
    if (index !== -1) {
      pageTitle = pageTitle.substr(0, index);
    }
    // -End
    pageTitleBar.setAttribute("titlepage", pageTitle);
    pageTitleBar.setAttribute("tooltiptext", pageTitle);
  }

  const observer = new MutationObserver(setPageTitle);
  observer.observe(document.getElementById("main-window"), {
    attributes: true,
    attributeFilter: ["title"]
  });

  const css = `
/* Movable titlebar */
:root {
  --pagetitle-bar-width: 350px;
}
#main-window:not([customizing]) #pagetitle-bar {
  -moz-window-dragging: drag;
  background: transparent;
  width: var(--pagetitle-bar-width);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0 10px;
}
#main-window:not([customizing]) #pagetitle-bar::after {
  -moz-window-dragging: no-drag;
  content: attr(titlepage);
}
#main-window:not([customizing]) #pagetitle-bar-image {
  display:none;
}
toolbarpaletteitem[place="palette"] > #pagetitle-bar {
  width: 7em;
  min-width: 7em;
  outline: 1px solid;
  outline-offset: -8px;
  opacity: .6;
  height: 37px;
}
#main-window[customizing] #nav-bar #pagetitle-bar {
  width: var(--pagetitle-bar-width);
  margin: 0 10px;
}
#main-window[customizing] #nav-bar #pagetitle-bar-image {
  display:none;
}
#main-window[customizing] #nav-bar #pagetitle-bar::after {
  content: "Page Title Bar";
}`;

  const sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
  const uri = makeURI("data:text/css;charset=UTF=8," + encodeURIComponent(css));
  sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
}());
Aris-t2 commented 4 years ago

The script and other scripts required the corresponding attribute from #main-window node. That attribute got removed by Mozilla on recent Fx builds, so that way of restoring the page title is gone. Maybe taking the title from current tab can work as a workaround.

peterwx commented 4 years ago

@tortious , So this is the script i currently use that i modified to work again. Without enumerating in detail the specific changes, it think those were xul>xhtml conversion, title(pageTitle var) has different source.

//Create a new custom toolbaritem, that has titlebar text displayed on it.
//If you're still not sure what it does check out the below.
//https://imgur.com/sXZrBMb
//https://imgur.com/a/GHvgjzu

(function(){
  if (location != "chrome://browser/content/browser.xhtml") {
    return;
  }
  let the_target = document.getElementsByTagName('title')[0];
  let the_title = the_target.textContent;
  try {
    CustomizableUI.createWidget({
      id: "pagetitle-bar",
      type: "custom",
      defaultArea: CustomizableUI.AREA_NAVBAR,
      onBuild: function(aDocument) {
        const toolbaritem = aDocument.createXULElement("toolbaritem");
        const image = aDocument.createXULElement("image");
        image.setAttribute("src", "chrome://branding/content/icon16.png");
        image.id = "pagetitle-bar-image";
        const props = {
          id: "pagetitle-bar",
          class: "chromeclass-toolbar-additional",
          titlepage: the_title,
          tooltiptext: the_title,
          pack: "center",
          align: "center",
          label: "Page Title Bar"
        };
        Object.entries(props).forEach(
          ([key, value]) => toolbaritem.setAttribute(key, value)
        );
        toolbaritem.appendChild(image);
        return toolbaritem;
      }
    });
  } catch(e) {}

  function setPageTitle(){
    if (document.getElementById("pagetitle-bar") === null) {
      return;
    }
    const pageTitleBar = document.getElementById("pagetitle-bar");

    let pageTitle = document.getElementsByTagName('title')[0].textContent;
    //let the_domain = document.domain;
    //remove the - Mozilla Firefox at the end of the title, delete the below line if you don't want it
    /*pageTitle = pageTitle.replace(/ - Mozilla Firefox$/, "");*/
    pageTitle = pageTitle.replace(/ - Firefox Developer Edition$/, "");
    //remove the - Mozilla Firefox (Private Browsing) in the title, delete the below line if you don't want it
    /*pageTitle = pageTitle.replace(" - Mozilla Firefox (Private Browsing)", "");*/
    pageTitle = pageTitle.replace(" - Firefox Developer Edition (Private Browsing)", "");
    pageTitleBar.setAttribute("titlepage", pageTitle);
    pageTitleBar.setAttribute("tooltiptext", pageTitle);
  };
  const observer = new MutationObserver(setPageTitle);
  observer.observe(the_target, {
    attributes: true, // attribute changes will be observed | on add/remove/change attributes
    attributeOldValue: true, // will show oldValue of attribute | on add/remove/change attributes | default: null
    characterData: true, // data changes will be observed | on add/remove/change characterData
    characterDataOldValue: true, // will show OldValue of characterData | on add/remove/change characterData | default: null
    childList: true, // target childs will be observed | on add/remove
    subtree: true, // target childs will be observed | on attributes/characterData changes if they observed on target
    /*
    attributeFilter: ['style'] // filter for attributes | array of attributes that should be observed, in this case only style
    */
  });

    const css = `
/* Movable titlebar */
:root {
--pagetitle-bar-width: 400px;
}
#main-window:not([customizing]) #pagetitle-bar {
-moz-window-dragging: drag;
background: transparent;
width: var(--pagetitle-bar-width);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin: 0 10px;
}
#main-window:not([customizing]) #pagetitle-bar::after {
-moz-window-dragging: no-drag;
content: attr(titlepage);
}
#main-window:not([customizing]) #pagetitle-bar-image {
display:none;
}
toolbarpaletteitem[place="palette"] > #pagetitle-bar {
width: 7em;
min-width: 7em;
outline: 1px solid;
outline-offset: -8px;
opacity: .6;
height: 10px;
}
#main-window[customizing] #nav-bar #pagetitle-bar {
width: var(--pagetitle-bar-width);
margin: 0 10px;
}
#main-window[customizing] #nav-bar #pagetitle-bar-image {
display:none;
}
#main-window[customizing] #nav-bar #pagetitle-bar::after {
content: "Page Title Bar";
}`;

    const sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
    const uri = makeURI("data:text/css;charset=UTF=8," + encodeURIComponent(css));
    sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
}());
Acelya-9028 commented 4 years ago

Hello everyone,

I'm working on a web extension that uses the sidebar to display data, with an input to filter that data. I need to bind a shortcut to focus this input, but I can't do it natively because there is no API to do it.

So I'm trying to use a userChrome.js script. I can inject js into the global context of the browser, but I can't find a solution to access my web extension context (in the browser#webext-panels-browser element in chrome://browser/content/webext-panels.xhtml).

Do you have any idea how to do this? It's possible?

I have tried M2, M3 and https://github.com/alice0775/userChrome.js/blob/master/73/userChrome.js, but it's the same, logic is the same between them.

For example, with M2:

UserChrome_js.prototype = {
  observe: function (aSubject, aTopic, aData) {
      console.log("domwindowopened:", aSubject, aTopic, aData);
      aSubject.addEventListener('DOMContentLoaded', this, true);
  },
  ...
}

The domwindowopened event is not triggered when browser#webext-panels-browser has loading. Maybe it's not the right name for the event I need?

Thank you for your help.

Aris-t2 commented 4 years ago

Maybe other events can trigger this.

Try "load" or "TabOpen" instead of "DOMContentLoaded"

albino1 commented 4 years ago

I'm using addonbar.uc.js and it works great, but one that that annoys me is that if I click on it and move my mouse it drags the entire Firefox window, like grabbing the Windows title bar and taking it out of fullscreen and moving it. This probably wouldn't be that big of a deal, except that I'm using it at the bottom of the browser as a divider between the browser and the Windows taskbar, and so often times when I go and click on something on the taskbar I miss by a few pixels and it moves the entire browser. Mostly user error, I know.

With that in mind, I thought I would at least ask if there was maybe a way to make the addonbar not act like the title bar? I don't think in most application clicking and dragging anything other than the titlebar moves the entire window. In fact, I'm also using the CustomCSSforFx fix which restores the File/Edit/View options at the top, and that bar where those are is draggable as well, which it probably shouldn't be. That probably means this is a Firefox application issue and is not solvable, but I figure it's worth asking. Thanks!

Aris-t2 commented 4 years ago

Edit the script and add this to the CSS area:

#addonbar { \
  -moz-window-dragging: no-drag !important; \
}\
albino1 commented 4 years ago

Wow, works great! I really didn't think that would be fixable, thanks so much!

Pizzapops commented 4 years ago

@Aris-t2 Today's Nightly update seems to have removed the old password manager. Password manager button opens a tiny no content window in the top left corner. Looks like we are stuck with Fx Lockwise and it's excessive empty space.

Aris-t2 commented 4 years ago

Thanks for the note.

Pizzapops commented 4 years ago

@Aris-t2 Lately, I have missed the old about:config ability to sort by by status. I modified about_button.uc.js. Left click = About dialog, middle click= old about:config & right click= new about:config. It works but right click also shows a popup menu. How do I disable the popup menu on a single button? about_button.uc.js.zip

Aris-t2 commented 4 years ago

Edit your even.button 2 area like this:

      if(event.button=='2') {
        try {
          gBrowser.selectedTab = gBrowser.addTrustedTab('about:config');
          setTimeout(function(){
            document.querySelector("#toolbar-context-menu").hidePopup();
          },0);
        } catch (e) {}
      } 
Pizzapops commented 4 years ago

@Aris-t2 Thanks, that did the trick.

peterwx commented 4 years ago

So i have just about 2 scripts that don't work in FF stable(regular edition) w/ M2. They work in FF Dev w/ M3 along a dozen or so other scripts. They are @xiaoxiaoflood's minMaxCloseButton.uc.js:

// ==UserScript==
// @name            MinMaxClose Button
// @include         main
// @shutdown        UC.MinMaxCloseButton.destroy();
// @author          xiaoxiaoflood
// @onlyonce
// ==/UserScript==

// original: https://j.mozest.com/ucscript/script/83.meta.js

(function(){
  if(location != 'chrome://browser/content/browser.xhtml'){
    return;
  }
  UC.MinMaxCloseButton = {
    init: function(){
      CustomizableUI.createWidget({
        id: 'minMaxClose-button',
        type: 'custom',
        defaultArea: CustomizableUI.AREA_NAVBAR,
        onBuild: function (aDocument){
          var toolbaritem = aDocument.createXULElement('toolbarbutton');
          var props = {
            id: 'minMaxClose-button',
            class: 'toolbarbutton-1 chromeclass-toolbar-additional',
            label: 'Window Button',
            tooltiptext: 'Left-Click: Minimize\nMiddle-Click: Maximize/Restore\nRight-Click: Exit',
            style: 'list-style-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAO0lEQVQ4jWNgYGD4jwWTBCg2gBSDSTKcYgNwGUqRzfQzAJcYxQYQBahiAE0SF7pBVEn2VHEJ/VyANQwACylDvQ9eqkEAAAAASUVORK5CYII=)',
            oncontextmenu: 'return false',
            onclick: 'UC.MinMaxCloseButton.BrowserManipulateCombine(event);'
          };
          for (var p in props){
            toolbaritem.setAttribute(p, props[p]);
          }
          return toolbaritem;
        }
      });
    },
    BrowserManipulateCombine: function(e){
      var win = e.view;
      switch(e.button){
        case 0:
          win.minimize();
          break;
        case 1:
          let max = win.document.getElementById('main-window').getAttribute('sizemode') == 'maximized' ? true : false;
          if ((!e.shiftKey && max) ||
              (e.shiftKey && !max && !(win.screenX === -5 && win.screenY === 0 && win.innerWidth === 1966 && win.innerHeight === 1050))) {
            win.resizeTo(1992, 1056);
            win.moveTo(-5, 0);
          } else if (max && e.shiftKey){
            win.restore();
          } else{
            win.maximize();
          }
          break;
        case 2:
          win.BrowserTryToCloseWindow();
      }
    },
    destroy: function (){
      CustomizableUI.destroyWidget('minMaxClose-button');
      delete UC.MinMaxCloseButton;
    }
  }
  UC.MinMaxCloseButton.init();
})();

which is similar in structure to movable_titlebar.uc.js which works in both FF editions w/ respective methods.

The other is about alltabs button dropdown list movable adapted from movable_ui.uc.js:

// movable ui
/*https://github.com/Patchonn/firefox-theme/blob/master/userChrome/movable_ui.uc.js*/
/*https://github.com/Pxuehtch/UCJS/blob/master/UCJS_files/206-NaviButton.uc.js*/
// movable ui

(function(){
  if(location != 'chrome://browser/content/browser.xhtml'){
    return;
  }
  let movable = [
    // unfortunately, these don't work like this
    //"PanelUI-button",
    //"nav-bar-overflow-button",
    "back-button",
    "forward-button",
    "alltabs-button",
    /*"urlbar-container",*/
  ];
  for(let id of movable){
    let the_elem = document.getElementById(id);
    try {
      the_elem.setAttribute("removable", "true");
      /**/
      if(id === "alltabs-button"){
        the_elem.style.fill = "#4169e1 !important";
      }
      /**/
    } catch(e) {}
  }
})();

In FF Dev one can w/ this script active move alltabs button to navbar and it persists across browser restarts, while with FF it doesn't persist although it can be moved.

Thanks for any insight into this.

xiaoxiaoflood commented 4 years ago

@peterwx my scripts rely on my method (M3), since they need some specific things that only my code implements. Like the shared global variable UC.

You can use my method in Fx release (stable), you don't need Developer Edition. You just shouldn't try to run my scripts using any method other than mine.

I think only my scripts are restartless, so you can disable/update them without restarting Firefox, just like an extension. Of course any script can be made restartless, but my scripts use a pattern that makes it easier to implement and read (like @shutdown, just like old bootstrapped addons had function shutdown(data, reason) {}).

Edit: I just noticed you (or someone else) edited my script. Mine doesn't have this:

  if(location != 'chrome://browser/content/browser.xhtml'){
    return;
  }

As this is already covered by @include main.

peterwx commented 4 years ago

@xiaoxiaoflood In fact as you stated M3 works (tested it) also on FF stable/release in addition to FF dev/pre-release. It wasn't possible to do that with some previous versions of FF stable i think. So all scripts work w/ M3 on stable. Maybe you could update your firefox-scripts page description to reflect that M3 is compatible also with FF stable? Thanks.

xiaoxiaoflood commented 4 years ago

@peterwx my repo doesn't say user userChromeJS doesn't work on Fx release. It has been like this for almost a year, since June last year. Before that it was said it it woudn't work because Fx was planing to do so. But after six months without removing support on Release, I decided to remove the warning that it wouldn't work on it. And last month Mozilla folks changed their mind and no longer plan to remove support.

But I reinforce that everything in my repository targets Developer Edition. So some scripts/addons may not work on other channels like Release or Nightly due to changes in each Fx version. I don't look at Nightly nor promote backwards compatibility with Release, let alone ESR.

peterwx commented 4 years ago

@xiaoxiaoflood Well now it makes more sense w/ sandbox prefs issue. Probably didn't pay much attention to it. FF folks(in the bugzilla link you provided), as you already noted, say they won't remove the sandboxing prefs from FF until otherwise needed. Thanks for your explanation.

Aris-t2 commented 4 years ago

I just wanted to throw my thoughts into this.

The scripts provided here do not rely on specific variables or content and should work with any method that allows to execute custom JavaScript code (not only those offered here). This of course does not mean scripts from other projects will work with this projects methods.

So in general I suggest to always try scripts first using the offered methods of the project they are from.

BoomerangAide commented 4 years ago

I wasn't satisfied with the icon from password_manager_button.uc.js so I adapted the code to use an image from the CustomCSSforFx project.

Changes:

Add:

var CustomCSSforFx_icon_filename = null; //change to the filename (without path) of an icon from CustomCSSforFx

below the comments and above the global function

Replace:

  var button_icon = 'chrome://browser/skin/login.svg';
  if (parseInt(Services.appinfo.version) < 68) button_icon = 'chrome://browser/skin/connection-secure.svg';an icon from CustomCSSforFx

By:

  var button_icon;

  if(CustomCSSforFx_icon_filename === null) {
    button_icon = 'chrome://browser/skin/login.svg';
    if (parseInt(Services.appinfo.version) < 68) {
        button_icon = 'chrome://browser/skin/connection-secure.svg';
    }
  }
  else {
    button_icon = 'file:///' +
            Components.classes["@mozilla.org/file/directory_service;1"].getService( Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile).path.replace(/\134/g,'/') +
            '/chrome/image/' +
            CustomCSSforFx_icon_filename;
  }

As said in the comment that I added on the first change, just need to set a filename without path from a CustomCSSforFx image as the value of CustomCSSforFx_icon_filename to use it. In my case, I have this:

var CustomCSSforFx_icon_filename = 'padlock_classic.png'; //change to the filename (without path) of an icon from CustomCSSforFx

Always good to have a little more flexibility ;)

MysteryIII commented 4 years ago

I'm using Addonbar script and it conflicts with Multirow Tab script and little with alternative searchbar script. Almost each time when Firefox opens a Popup (like asking for opening many tabs at once or when reloading asking to resend data) the Multirow Script suddenly stop working (totally). If I open a new window, it will work again. For the searchbar script it will change Icon to normal one and "one click search" for other searchengines when typing doesn't appear. However normal change of search engine is still possible.

Aris-t2 commented 4 years ago

"Alternative search" and "Add-on Bar" scripts work well together and do not have issues with other toolbar scripts provided here.

I can not tell anything about "multirow tabs toolbar scripts" provided by other JS projects.

MysteryIII commented 4 years ago

Weird, maybe the reason lies somewhere else for the normal Icon appearing in "Alternative Search". However for finding the reason for Multi Row stopping to work, I deleted all other scripts. On Camp Firefox I asked for help and they provided me an alternative script for the bar that doesn't conflict, but flexible space bars are not working flexible and also right click behaves like click on menu bar. I was hoping to keep your more advanced script, just rooting out the issue with Multi Row.

Aris-t2 commented 4 years ago

I have an idea for you initial issue. Increase the delay value before scripts are actually loaded: https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/alternative_searchbar.uc.js#L45 (change 1000 to 2000 or 3000)

https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/addonbar.uc.js#L128 (remove the targeted line and enable the code below, it contains a delay value too)

MysteryIII commented 4 years ago

Great, thanks! Using the delay option fixed it.

MysteryIII commented 4 years ago

Addition: Using the delay value in addonbar will cause heavy freezes in Firefox after a while with many tabs open in Multirow. So this solution leads to a bigger problem, sadly.

Speravir commented 4 years ago

Ha, I came her to ping you, Aris, but as far as I see the complaint in Addonbar Skript verursacht Fehler/Ausfall in anderen Skripts (camp-firefox.de) is very similar to MysteryIII’s problem.

Aris-t2 commented 4 years ago

Still wondering why I can not reproduce any of the mentioned issues. The "fix" in the other thread contains a check for browser.xhtml file. Maybe that is the reason. Try to add this code after init: function() {

if (appversion >= 76 && location != 'chrome://browser/content/browser.xhtml')
      return;