Bookmark Bar only on Speed Dial (like chrome)
-
UPDATE: Sorry for the trouble everyone, turns out, I had to show the Bookmarks bar (I've kept it turned off all this while), then restart Vivaldi with that, and now it works! Thank you so much everyone who offered their precious time and effort to help me, cheers!
-
@CharlieMHz happens to the best!
-
This doesn't works.
-
This post is deleted! -
@masterleo29 Doesn't seem to be working ?
-
@dpn Hi. Seems Vivaldi has updated some internal namings. I've updated it and tested. Let me know if it works for you
/** * Author: Leonardo Domingues */ setTimeout(function wait() { var adr = document.querySelector(".toolbar-mainbar.toolbar"); if (adr != null) { const vivaldi = window.chrome; var bar = document.getElementsByClassName('bookmark-bar')[0]; function change_display() { var tab = document.querySelector('.active.webpageview'); if (tab.classList.contains('internal')) { bar.style.display = "flex"; }else { bar.style.display = "none"; } } vivaldi.tabs.onCreated.addListener(e => change_display()); vivaldi.tabs.onUpdated.addListener(e => change_display()); vivaldi.tabs.onActivated.addListener(e => change_display()); } else { setTimeout(wait, 300); } }, 300);
-
@masterleo29
.toolbar-addressbar
changed to.UrlBar
a few updates ago if you want to use that in thequerySelector
foradr
. -
@masterleo29 Hi Master, Thanks. But unfortunately, this did not work for me.
-
@nomadic Tried swapping those values; didn't work either.
/** * Author: Leonardo Domingues */ setTimeout(function wait() { var adr = document.querySelector(".UrlBar"); if (adr != null) { const vivaldi = window.chrome; var bar = document.getElementsByClassName('bookmark-bar')[0]; function change_display() { var tab = document.querySelector('.active.webpageview'); if (tab.classList.contains('internal')) { bar.style.display = "flex"; }else { bar.style.display = "none"; } } vivaldi.tabs.onCreated.addListener(e => change_display()); vivaldi.tabs.onUpdated.addListener(e => change_display()); vivaldi.tabs.onActivated.addListener(e => change_display()); } else { setTimeout(wait, 300); } }, 300);
-
@dpn Hum .. Just to be sure, you have the "show bookmark bar" activated, correct ? I'm asking 'cause I tried (with it on) on the snapshot and it worked. Do you have Vivaldi up to date ?
-
@vegardheimdal You missed the purpose of a JS mod: to modify Vivaldi UI.
Extensions & user scripts don't work on Vivaldi UI (or any chromium-based browser UI afaik), that's why you need to put it in the application folder, otherwise it will do nothing.
-
@masterleo29 Sorry, the script does work. I think the problem was, I put an underscore in the file name .
The script shows the bookmark bar on the settings page too .
I tried the script with both the different querySelector values ( .toolbar-addressbar and .UrlBar ) and they both worked.
Unfortunately the script doesn't work when the Start Page / New Tab Page is controlled by an Extension. Which is a shame, because that's the set-up I have, specifically my NTP is controlled by the 'Earth View by Google Earth' extension.
-
@dpn Made some edits to get it working on extension controlled new tab pages and top showing up on other internal webpages.
setTimeout(function wait() { const bar = document.getElementsByClassName("bookmark-bar")[0]; if (bar != null) { function change_display(tab_data) { let bar = document.getElementsByClassName("bookmark-bar")[0]; // BUG-FIX: listeners don't all give the same information, so need to extract tab ID differently let tabId = tab_data.tabId ? tab_data.tabId : tab_data.id ? tab_data.id : tab_data; chrome.tabs.get(tabId, (tab) => { // get specific page url set as new tab page if it is set vivaldi.prefs.get("vivaldi.tabs.new_page.custom_url", (customUrl) => { // get the new tab url even if it is pending const url = tab.url ? tab.url : tab.pendingUrl; // check if the tab is the internal startpage, // an extension controlled new tab page, or // a specific page set as the new tab page const startpage = document.querySelector(".webpageview.active.internal .startpage") || url === "chrome://newtab/" || (customUrl && url === customUrl); if (startpage) { bar.style.display = "flex"; } else { bar.style.display = "none"; } }); }); } let main = document.getElementById("main"); let mainObserver = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { const addedNodes = Array.from(mutation.addedNodes); addedNodes.forEach((element) => { if (element.classList.contains("bookmark-bar")) { chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { change_display(tabs[0]); }); } }); }); }); mainObserver.observe(main, { childList: true }); chrome.tabs.onCreated.addListener(change_display); chrome.tabs.onUpdated.addListener(change_display); chrome.tabs.onActivated.addListener(change_display); } else { setTimeout(wait, 300); } }, 300);
Edit: Also added support for new tab pages set to a specific page URL.
Edit 2: Improperly handled different listener event data, now fixed.
Edit 3: Updated for v4 -
@nomadic Thank you. Much appreciated.
It has one problem I've found; when in the settings you have 'Open Bookmarks in New Tab' unticked, when you open a Bookmark from the Bookmark Bar on the New Tab Page, the Bookmark Bar does not disappear when the link opens ?
-
@dpn Any idea what the problem is anyone ?
-
@dpn It should work theoretically. The mod uses the
chrome.onUpdated
api, which should trigger when the URL changes. Check console for errors. -
I find it more useful to Autohide the Bookmarks Bar then you can show it only when you need it, whether that is on the Start Page or any web page. It even works on the About page.
-
@luetage I don't really know what I'm looking for here, is this it ?
VM149:5530 crbug/1173575, non-JS module files deprecated. (anonymous) @ VM149:5530
-
@dpn No, it should be an error that shows your custom modification file. Did you inspect the User Interface? Read here ☛ https://forum.vivaldi.net/topic/16684/inspecting-the-vivaldi-ui-with-devtools
-