Set the browser's tab background color with browser extension/addon - google-chrome-extension

Is there any way of setting the browser's tab background color (not the favicon image) and text color with the help of an browser extension/addon.
I've searched the internet to and fro and found nothing in the APIs. So I think it is not possible. But maybe someone has a solution for that.
What I want to achieve is to tint the colors of TYPO3 tabs according to the application context (Development, Production/Staging, Staging). I managed to set the top-bar color in the TYPO3 backend depending in the application context, so the logic works well. What I'd like to have now is a way of tinting the tab.

You are right: there's nothing in Firefox or Chrome API that allows you to color individual tabs easily. But there are some workaround ideas..
Colorful Tabs uses theme override to style individual tabs, including (by default) based on domain, using the browser.theme API that only Firefox supports. However, after trying it out, it might not fit your requirements: in current Firefox version it only affects the color of the currently selected tab (and the address bar), not providing you with a good overview.
Some other extensions for Firefox, for example TST Colored Tabs use sidebar tab representation that duplicates the tab bar, with possible enhancements. Also not ideal, and also Firefox-specific.
For Chrome, there's a Chrome-specific API tabGroups that can add color outline to tabs, but only by adding them to a group. You can have many groups, but it's still going to be ugly if your tabs are interspersed or moved around.
So let me propose an out of the box solution: use a custom favicon per application context instead of trying to change how the tab UI looks. That would be always visible in the tabs strip without any code on the browser's part. You could also override favicons from extension code if there's no easy way to do it on the application side.

Related

Toggle Chrome Extension Icon based on light or dark mode browser?

I've tried searching for this, and the closest related question that I could find was from 3+ years ago and had to do with the incognito window being dark, while a normal chrome window was light back then.
Now that we have the ability to have a light or dark mode browser, it's hard to find an icon design and color that looks good for both light and dark modes. Here's an example:
In the image above you can see that the first and third icons are black, so they are hard to see when using dark-mode. The middle icon (the one I'm using for my extension)looks great on dark mode, but terrible on light mode. See below:
So does anyone know if there is there a way to detect the browser mode (light or dark) and swap out the icon?
Thanks to wOxxOm I was able to figure this out.
First, I needed to create a content script (which I called toggleIcon.js) and add it to the manifist.json file.
Then I added the following to toggleIcon.js - which sends scheme: "dark" to my background.js file if window.matchMedia matches prefers-color-scheme: dark.
Then in my background.js file I listen for that message, and if request.scheme == "dark" I use chrome.broserAction.setIcon to change the paths for each of my icons to the dark version.
This effectively overrides my original icon paths as declared in the manifest.json file (as shown below).
The only downside I see is that this requires a content_script, which if you want your extension to work on any page, requires you to also add "matches": ["<all_urls>"] to your extension, which slows down the approval process. Which is why in my comments above I mentioned I had been avoiding using a content_script.
Also, I think it makes sense to use the version of your icons that work best on light-mode as your default, because I think the chrome extension page will pull from these for some of the icons they use (and that page has a white background). As an example, here's how my old icon looked (not enough contrast).
Hopefully this helps someone else!!

Setting italic in RichtText

I am displaying richtext on my web page. and have added an italic text, but it does no show as italic, just normal text.
when I look in developer tool it looks like the xsp.css is setting font-style to inherit but I can't decide what it inherits from.
how can I find out what is causing the italic to not being set correctly?
I created an empty database with a form and an xpage and seem to get the same problem
the result is the same in Chrome, Firefox and IE
In Developer Tools go to the second tab on the right called Computed. Here you can find "font-style" and see what style sheets are used to compute the styling.
Here's an example from an XPages app that uses the OneUI theme:

Force tab to render

Is there a way to force a certain tab to render, even without currently being the active tab?
The reason i need to do this is because my extension uses chrome.tabs to open multiple tabs and switch between them, and whenever I switch to a tab which has not yet been active, the tab has not rendered yet, which causes a white flash to appear on the tab until the tab renders. The duration of the white flash is also proportional to how heavy the web page is to render.
What I've noticed though, is that if you switch to a tab which was active at least once in the past, the white flash does not appear (since it has been rendered at least once in the past)
I need to force a tab to be rendered before switching to it, so that the white flash doesn't appear.
I am writing on chrome version 38 (due to technical restrictions)
Thanks
No. You can't control it.
The white flashing is indeed an annoying known issue.
The only wild idea that can be implemented right now:
create a new minimized window with a blank url or about:blank,
move the tab you need into that window via chrome.tabs.move
now that the tab is active Chrome should render it even in a minimized window
then after a while move the tab back and activate it

Google Chrome Extension Development

I am developing a chrome extension that would like to add a tab at the bottom of the page to manipulate DOM elements. Chrome 'manifest.json' file doesn't provide such feature. So how to do it or rather how does Firebug add a tab at the bottom of the Chrome?
I would suggest inserting a panel in every page through a content script. You can style it in order to appear at the bottom of the page and be always visible.
In order for it to retain its state between navigation from one page to another, you need to persist it some how (example use chrome.storage or a similar mechanism through the background page to persist the content (or whatever you need).
See this answer on how to insert (and style) a toolbar-like div or iframe in a page through a content script. (It is fixed to the top of the page, but you can easily modify the code to fix its position at the bottom.)

Nav menu that spans entire container width with constant horizontal padding

I've created a nav menu like in the screenshot below. It spans the entire width of the container and the left/right padding of each menu item is constant. This was easy to do by hardcoding the left/right padding in the CSS, but I want the paddings to be able to change as the site admin edits the menus.
Is there a way to do this with pure CSS (CSS3 is okay)?
This was easy enough to do with jQuery (I totaled up the width of the menu items and calculated the necessary padding). But I ran into some issues on some browsers due to our use of Google Web Fonts. On Chrome and Firefox 4 on Windows (not on Mac), the web font was not loaded at the time that my script ran, resulting in incorrect width measurements. I tried running the script in the jQuery's DOM ready event and in the Google Font API's active event. The active event worked in Chrome but in Firefox 4 it was often fired before the font had been applied.
Thanks in advance.
Here's a jsfiddle of a potential different solution.
Using that layout, and assuming the number of menu items is going to change, you call a recalculation method once a list item is added/removed. In this example provided, I've used YUI3 to do the DOM manipulation, but you could do that a number of ways. Note - I didn't test the javascript function, its "probably working pseudo code".
(You may need to make subtract a further 2% or so from the list item widths, if you're trying to deal with IE6/7)
Use jQuery's .load event as suggested by user thirtydot.

Resources