Closed Aris-t2 closed 5 years ago
The download window code does the job 👍
The restart button script offers 'clear script caches' via middle click. Its what I use, but the shortcut is also an easy way to achieve this. 👍
Middle click sometime is blocked on Windows 10 without reasons.
Never happened here. Maybe a conflict with your mouse driver/software/setup.
Hey @Aris-t2 I tried to changed the location to Chrome\Userchrome ,
toolbarbutton#characterencoding-button { -moz-binding: url("/userchrome/userChrome.xml#js");
but it didn't work did i make something wrong please fix it
Make sure the "character encoding" button is on your toolbar, e.g. navigation toolbar. Otherwise it won'T work.
Or script is outdated...
Hi,
Wanted to share experiences, in case it help future users.
I tried transferring my customization from my laptop (Firefox 65 32 bits, Windows 10 Pro 32 bits 1709) to my surface pro tablet (Firefox 66 ?? bits, Windows 10 Pro 64 bits 1809 I think), but at first, nothing worked. The browser console was showing something about illegal UTF8 character or something, and at first, I thought it was because method 1 was broken on the new setup (that was probably wrong, but at least now I have a test ground for method 3). I eventually had to open all .js files, and convert them to UTF-8, for it to work. My laptop don't care about encoding, don't know which config element caused this, but I converted the files to be ready.
Another thing that didn't work was a piece of code I wrote to move Back and Forward buttons to the personal bar. They got moved to the end instead of the beginning. Managed to fix it by using the setTimeout function like in the alternative_searchbar.uc.js script. I think this may have been caused by faster hardware/SSD.
I hope nobody run into the same issues, but if someone do, my experiences may help.
@LionWrathz: you don't need to put the . at beginning of url or set caps right on the folder name?
set caps right on the folder name?
Windows no detect small and big letters.
@BoomerangAide
All files are in UTF-8 before uploading according to Notepad++. Not sure, if that information gets lost after transferring the code to a new .js file manually via copy&paste.
Hi @Aris-t2, Just checked out your favicon_in_urlbar script. Looks good, still there is a small question I would like to ask. By default when there is a custom permission for a specific site a regular "i" icon changes to "i with a dot". Is it possible to add something similar to the mentioned script (aka to be able to define whether there is a permission change in place)?
Also maybe you can help with another request. When adding a newBookmark/editingBookmark (via Star icon in URL bar or any other way) a popUp comes in. It has an button "show all bookmarks in folders". When clicked it allows to select destination folder for the bookmark (for the same of simplicity leth call this an "extended view"). Is it possible to make a script that will trigger the "extended view" instead of the regular one when bokmark event is trigerred? Lastly maybe there is a way to increse the tree view height of the "extended view"?
TXH in advance.
Post an example site.
For the other request try this: https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/editbookmarkspopup_expanded.uc.js
hi @Aris-t2 Thank you for the quick reply.
chrome://browser/skin/identity-icon.svg
(left section of the screenshot.)
Later if we add some permission to the site (for example allow autoplay sound via about:preferences#privacy > Block websites from automatically playing sound > exceptions)
the icon changes to
chrome://browser/skin/identity-icon-notice.svg
(right section of the screenshot).
This behavior is applicable to any specific permission that might be added to the siteI do understand that this might be a bit tricky because this logic relies on two different icons, and one of them acts as "default". Still maybe you will find some sort of workaround in form of graphical overlay/style/shadow etc
It is possible to recreate the badge on top of the current icon for pages with granted permissions. Test the updated script.
I had to rewrite the script for it to work with Fx60-68. Look like the only clean way to apply CSS is still registering style sheets. ;-) Test the updated script. I removed the transition/animation, because switching between expanded tree view and normal tree view always causes popup jumps and hickups and they look ugly when the popup just opens. You can remove the part of the code and test the version without transition removal. (Remove this rule https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/editbookmarkspopup_expanded.uc.js#L36)
You are the best, @Aris-t2 !!! Confirming, both are working fine. Regarding animation, its a bit sad that we need to remove animation to fix the hickups. Also maybe its just me, but I still see those hickups (of course less noticable then before).
How would I be able to add a icon to the nav toolbar?
I was able to grab the extension files after removing source extension and have located the icon but I'm not sure what to do next.
I'm running Firefox 66.0.3 and currently use method 1 for other JS "hacks".
Thanks for the favicon_in_urlbar.uc.js script.I was using another one, but your is working better.
The only change I made was to replace favicon_in_urlbar = 'chrome://branding/content/identity-icons-brand.svg';
by favicon_in_urlbar = 'chrome://image/tab_favicon_sheet.png';
because it fit my CustomCss logic better, not sure if that was the best way to go about it, but that's an use case.
The only mystery I haven't solved, is that when I open a new tab, it has a Firefox icon (and that's probably a bug in the first place), but the urlbar can't seem to get this icon (get empty sheet icon with my change), but that's not a big deal, unless it's hiding an issue that could be more of a problem in other circumstances?
Anyway, thanks again.
@BoomerangAide guess Firefox icon comes from this line https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/favicon_in_urlbar.uc.js#L28
BTW, here is the path to the default globe icon chrome://mozapps/skin/places/defaultFavicon.svg
@Acid-Crash I don't think there is much to improve regarding the hickups. The script "switches" to expanded view as soon the popup opens. Looked better in the first version of the script, but as you reported, it was not for Fx68+.
@That-Random-Guy I'm not sure what your question has to do with this repository. Creating a toolbar button with an icon is possible (look at the other buttons scripts), but what would that button do?
@BoomerangAide The script looks several times during loading for a favicon. Sometimes pages don't offer any or use internal ones (like some about pages). In those cases current brand icon is used (its not a bug).
Edit I updated the favicon script again. Now one can chose between icons inside browsers default files like i-icon, sheet, brand and globe.
@BoomerangAide Does the new sheet icon option work the same way your previous code change did?
@Aris-t2 Gotcha—I'll look into that then. If I have any further questions, where should I direct them?
@That-Random-Guy Honestly, I have no idea. There is no "request" area for stuff like that. Maybe on Reddit or Mozillazine.
What is your button supposed to do anyways?
Edit: If you understand German, you can find a big Fx tweaks community on Camp Firefox forums where users ask for new stuff possible with CSS or JS all the time. ;-)
@BoomerangAide Does the new sheet icon option work the same way your previous code change did?
Actually things were working in an unexpected way.
I had a custom css to use the empty sheet as a default in urlbar, and I think my previous code change was causing a bug, that allowed in some cases the icon I wanted to appear, but also preventing the firefox icon on new tab to be used.
Now after testing the sheet option and seeing it was different from UserChrome.css, I'm using an added line var sheet2 = 'file:///C:/Users/MyName/AppData/Roaming/Mozilla/Firefox/Profiles/ProfileName/chrome/image/tab_favicon_sheet.png'
This allow to use the sheet, firefox icon or site icon properly...I hope lol.
I wonder if there would have been a shorter way for the path though.After figuring I had to use file:///
I didn't retry a relative path (starting with '.'), or maybe there would have been a chrome:///
path that would have been able to access UserChrome.css project images?
Check this out about relative and absolute paths: https://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/
Hi @Aris-t2. Is it hard to modify "View Image" context menu entry (or create a separate entry for this task) so it would open image in New Tab instead of the current Tab by default?
P.S. I do know that holding Shift achieves the same, still, the default new tab behavior would be neat...
I have not checked yet, but using middle-click also opens a new tab. ;-)
Hi Aris,
Hoping you can help. I've got a Paste & Go button with code that works perfectly in Custom Buttons (FF 66.0) but will not as a script button. I think the problem is copying to the clipboard but I can't nail the error down. Could you please take a look at it? This is the active code used in custom buttons:
var myURL = gClipboard.read();
if (myURL.substring(0, 8) == "https://") { //window.open(myURL); gBrowser.loadURI(myURL, { triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), }); } else { if (myURL.substring(0, 7) == "http://") { //window.open(myURL); gBrowser.loadURI(myURL, { triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), }); } else { gBrowser.loadURI("http://" + myURL, { triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), }); // alert("URL error. Clipboard contents are:- " + myURL); } }
I've made dozens of buttons using the same full script button, with the only changes being the active code, icon and ID. This is the only one I can't get to work.
@marty60
"gClipboard.read();" does not have access to the clipboard. I wrote a complete script incl. button creation for testing purposes.
// GetUrlFromClipboard button script for Firefox 60+ by Aris
//
(function() {
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 = "test";
CustomizableUI.createWidget({
id: "gufc-button", // button id
defaultArea: CustomizableUI.AREA_NAVBAR,
removable: true,
label: button_label, // button title
tooltiptext: button_label, // tooltip title
onClick: function(event) {
var myURL = '';
navigator.clipboard.readText().then(text => {
myURL = text;
if (myURL.substring(0, 8) == "https://") {
//window.open(myURL);
gBrowser.loadURI(myURL, {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
} else {
if (myURL.substring(0, 7) == "http://") {
//window.open(myURL);
gBrowser.loadURI(myURL, {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
} else {
gBrowser.loadURI("http://" + myURL, {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
// alert("URL error. Clipboard contents are:- " + myURL);
}
}
}).catch(() => {
//console.log('Failed to read from clipboard.');
});
},
onCreated: function(button) {
return button;
}
});
// style button icon
var uri = Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent('\
\
#gufc-button .toolbarbutton-icon {\
list-style-image: url("chrome://browser/skin/forward.svg"); /* icon / path to icon */ \
fill: red; /* icon color name/code */\
}\
\
'), null, null);
sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
})();
@Aris, that works perfectly, thanks a lot. It saves me the trouble of installing another addon for such a simple command.
Hey #Aris-t2 I tried to modified the scrollbar, to reduce the white space but can't find it ,can you help me ? thanks. https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/custom_scrollbars.uc.js I know there it must be like that to reduce it but cant find it
scrollbar[orient="vertical"] { -moz-margin-start: 0px !important; max-width: 10px !important; min-width: 10x !important;
https://i.imgur.com/p80RIxo.jpg
I want to make it look like this.. https://i.imgur.com/hWjQbaG.png
If you are using https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/custom_scrollbars.uc.js
, you can set a lot of stuff for the scrollbar, so it looks more like what you want. Test this code:
If you are using
https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/custom_scrollbars.uc.js
, you can set a lot of stuff for the scrollbar, so it looks more like what you want. Test this code: scrollbars
Thank you so much it worked now that's what i wanted
Hi @Aris-t2 Firefox 67 added a "Logins and Passwords" to the App menu. Could you please check if your password_manager_button.uc.js uses the same entry (maybe it is worth using the same for longevity reasons)?
Currently this add-on uses
window.open('chrome://passwordmgr/content/passwordManager.xul','', 'chrome');
while default menuitem uses
LoginHelper.openPasswordManager(window, { entryPoint: 'mainmenu' })
;
Both do the same atm.
@Aris-t2, did you notice?
Milupo in Re: Aktuelle Nightly Version - Scripte funktionieren nicht mehr (German). Some of your scripts are affected, too. In English: Replace every createElement
with createXULElement
, but not createElementNS
.
I did this back then when it was introduced for Fx63: https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/addonbar.uc.js#L78
Hi @Aris-t2. Is it possible to create script that will create a toolbar button based on a specific bookmark (bookmark name is static)? A small background why I'm asking about this: from time-to-time I need to use some bookmarklets (a piece of JS code that is saved as an bookmark). Typically they interact with an active tab (reload page CSS, access Google cache, use Google translate). Here is one of them http://lea.verou.me/2018/09/refresh-css-bookmarklet-v2/
So I'm curious if it is possible to make a button out of them. If concept "paste from bookmarklet" is to complicated maybe if is possible to make a plain toolbar button that will literally execute a piece of JS defined by user...
It should be possible to attach own code to a newly created button. You can use the "Restart button" as base and replace the code in lines 35-48 with own JS code, such as provided within the function of the linked script for example.
@Aris-t2 Bad luck for me((( It doesn't work.
Here is what I've tried...
Seems like it tries to interact with browser "internally" instead of the opened web page. When trying to use Google Translate bookmarklet
document.location = 'http://translate.google.com/translate?js=n&prev=_t&hl=ru&ie=UTF-8&layout=2&eotf=1&sl=auto&tl=ru&u=' + top.location.href + '&act=url'
it gives the warning Bad URL: http://browser/content/browser.xhtml
Also both JS are working fine when are executed from the DevTools console.
Not sure how to access the webpage from the script, but my guess is "document" has to be replaced with something, that has deeper access.
Hello Aris,
To run scripts I was using xiaoxiaoflood's method 3 but it's broke in 69 and his project appears dead, at least for now so I'm using method 1. That does work but it had to be updated with Alice's userChrome.xml:
One of your scripts MovableUrlbar I modified slightly to make the forward button moveable instead:
`// Movable forward button script for Firefox 60+
var {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {}); var {CustomizableUI} = Components.utils.import("resource:///modules/CustomizableUI.jsm", {});
var MovableUrlbar = { init: function() {
try {
document.getElementById('forward-button').setAttribute('removable','true');
} catch(e){}
try {
if(!document.getElementById('forward-button').getAttribute('cui-areatype'))
document.getElementById('forward-button').setAttribute('cui-areatype','toolbar');
} catch(e){}
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
try {
if(!document.getElementById('forward-button').getAttribute('cui-areatype')) {
CustomizableUI.addWidgetToArea("forward-button", CustomizableUI.AREA_NAVBAR);
} else if (document.getElementById('forward-button').getAttribute('cui-areatype')=="menu-panel") {
CustomizableUI.addWidgetToArea("forward-button", CustomizableUI.AREA_NAVBAR);
}
} catch(e){}
});
});
try {
observer.observe(document.getElementById('forward-button'), { attributes: true, attributeFilter: ['cui-areatype'] });
} catch(e){}
}
}
MovableUrlbar.init(); ` The problem I have is unlike xiaoxiaoflood's version every time I close the browser the forward button is back on the navbar. I have it moved to the menu bar but it's kind of useless if it doesn’t stay there. Is there any way to force it to through the code?
@marty60 Thanks for sharing. Alice's method looks to me like an entirely different implementation of the way to load js scripts, so I don't think of it as an extension of "method 1", but more like a "method 4" for example. I have to take a deeper look at the code.
For me this projects "method 2" still works with every Firefox version, while "method 1" stopped with Firefox 68+. I suggest to try it.
About your problem with movable urlbar and buttons: After every restart the browser resets the configuration of back button, forward button and location bar. To make your change stick on a fixed position one has to use my script and chose the position of those items on the desired toolbar. This was the only way in my tests to keep the position after a browser restart. This also means changing the position only sticks, if done via the js file and not customizing mode.
Test this script: https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/move_urlbar.uc.js
Method 2 does work as well but its config.js conflicts with custom buttons config.js, even if I change the custom buttons config.js to another name, custom buttons will continue to load and work properly but the scripts won't run. Method 1 doesn't give me that problem.
Your script does the job for setting the position of the buttons but I'm not sure if that is the same as to what I was referring to. After I move the forward button to the menubar, close then reopen the browser it's back on the navbar so each time I have to put it back on the menubar. I'm looking to keep it fixed on the menubar because it won't stay there.
What would happen with xiaoxiaoflood's is that it would start out on the navbar when first opening the browser then automatically move it to the menubar or wherever you placed it. Neither method 1 or 2 does that. Is there perhaps some css code that would fix it to menubar?
Can't say much about config.js of custom buttons. Never used or tested it, but normally user scripts should be able to run from where other user scripts run. Rename that file to custom_buttons.uc.js and import it though userChrome.js.
As far as I understood you want to move the forward button or for it to be movable, but this does not work anymore, not even with a script, that allows it to be movable. Only a script that defines a fixed position on a toolbar works.
Custom buttons is an addon that uses the experiments format and to make it work it has config.js settings.
Using Alice's userChrome.xml and the other two files from method 1 there is no conflict and scripts run fine. So I am able to move the forward, back, and url buttons to the other toolbars, it's just that they don't stay there when you close the browser.
You can also try to keep that configuration, but use https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/move_urlbar.uc.js instead of the forward button script you mentioned before.
The button does not stay, because that script can not make it stay, but my script can. You can also edit it and only keep the "forward-button" parts and remove everything else.
var {CustomizableUI} = Components.utils.import("resource:///modules/CustomizableUI.jsm", {});
var navigation = CustomizableUI.AREA_NAVBAR;
var tabs = CustomizableUI.AREA_TABSTRIP;
var menu = CustomizableUI.AREA_MENUBAR;
var bookmarks = CustomizableUI.AREA_BOOKMARKS;
/* [target toolbar of item]
menu = 'menubar'
tabs = 'tabs toolbar'
bookmarks = 'bookmarks toolbar'
navigation='navigation toolbar' */
var forwardbutton_on_toolbar = menu;
/* [target position of item]
0 = 1st
1 = 2nd
2 = 3rd
...
x = xth */
var forwardbutton_on_toolbar_position = 0;
var MoveForward = {
init: function() {
try {
document.getElementById('forward-button').setAttribute('removable','true');
} catch(e){}
CustomizableUI.addWidgetToArea("forward-button", forwardbutton_on_toolbar);
CustomizableUI.moveWidgetWithinArea("forward-button", forwardbutton_on_toolbar_position);
try {
document.getElementById('forward-button').setAttribute('removable','false');
} catch(e){}
}
}
document.addEventListener("DOMContentLoaded", MoveForward.init(), false);
Thank-you Aris, that finally did it. The original code you posted wasn't allowing me to move anything but this revised code you just posted works great. I just had to change the postion from 0 to 1 because I've got a custom back button. But it is holding its position and on the menubar after rebooting.
Edit: there was another change I had to make to the above code. When opening a new window the forward button would be back on the navbar but changing this line from false to true seems to fix that:
try { document.getElementById('forward-button').setAttribute('removable','false'); } catch(e){}
@Aris-t2 could you please create a new scripts about New TAB blank pages to make New Tab pages
transparent? that code you give me it stop working.
41 (comment
Firefox 67
New tab page does not work like that anymore and the "main-window" tag does not show proper "New Tab..." title always anymore, so such a script can not be achieved.
Maybe making about:home/about:newtab page transparent might help you, Add this to userContent.css
@-moz-document url-prefix(about:home), url-prefix(about:newtab) {
* {
opacity: 0 !important;
background-color: transparent !important;
}
}
How to recover arrow in search input on about:home
left FX 68 right Nightly 69
with crap search
Script no needed now:
browser.newtabpage.activity-stream.improvesearch.handoffToAwesomebar
- false
Also possible active relases: https://github.com/Aris-t2/CustomJSforFx/releases
with small changelog?
Lets discuss everything related to JavaScript here instead of opening new threads for questions or request.
Custom scripts https://github.com/Aris-t2/CustomJSforFx/tree/master/scripts
Other custom script collections - by ardiman - by Endor8