How to remove openerTabId property of a vivaldi tab?
-
Does anyone have an idea how to set the openerTabId of a tab to null/undefined. Currently I am trying with the code below, but it's not working.
chrome.tabs.update(tabId, {openerTabId: null}, someCallback)
-
What code are you using exactly, somecallback will not work
And what error does it throw in console, or is there just nothing? -
There's no error in the console. Tha callback is a function that was just logging the updated tab that was passed to it.
-
I'm not sure chrome allows you to change the tabID. Did you find working example code anywhere? – Because I couldn't so far. We can certainly check for tabID and act on it, but change it? Hmm.
-
The code you're trying to run will only be valid in the context of a chrome extension. Not a Vivaldi browser.html mod
-
@luetage Here says it's possible to set openerTabId: https://developer.chrome.com/extensions/tabs#method-update
@LonM If so why is the API actually working. There are no errors at all (if I use it correctly) and I receive the expected return values
-
@kakato10 You're right. I just remembered that the browser.html does actually run in an context that exposes this stuff.
How could I forget, only a few days ago I was doing the same thing with the storage api. I must have not been thinking properly (I was mid-commute when I posted my earlier reply).
Tried it just now and it works for me, but I have some pointers:
- Chrome dev docs say that the callback is optional - you don't need it, so don't write a dummy name
- The tab ID refers to the tab object ID, NOT the position on the tab bar or the index as retrieved by
chrome.tabs.query
- This is my code that worked:
chrome.tabs.update(11, {openerTabId:13})
I'd be interested to know what you're building. Beyond some minor investigation of the data storage Vivaldi has, I hadn't considered building mods that use the chrome extension API (I could use that to store custom mod settings or something...) so thanks for correcting me just now .
-
The dummy callback was just for the forum, in my code it's an actual function.
If I pass a number which is an actual tab Id it works, but I want to unset the openerTabId, so that I remove the link between related tabs..
I am trying to implement Firefox like new tab behavior.
https://forum.vivaldi.net/topic/25707/option-to-periodically-destroy-the-link-between-related-tabs/3 -
@kakato10 Looking at the API docs, I'm not sure if there is a way to "unset" a property. From what I can tell if you update this property, then you have to update it to something valid. The only time it gets cleared is if that opening tab is closed.
If you could figure out a way to open a new tab, get that tab's ID, set it to that, and then close it, then you can clear it:
function clear_opener_id(target_to_clear_id){ chrome.tabs.create({}, newtab => { chrome.tabs.update(target_to_clear_id, {openerTabId: newtab.id}, updated_tab => { chrome.tabs.remove(newtab.id); }); }); }
The problem then is that you get an ugly quickly opening and closing tab on the screen. If you knew of a way to send this to a "dummy" window or something so that it's not visible, that might work.
-
This might be a way, but the animations, will most likely annoy me. Will try it when I have time.
Thanks a lot, for thinking on it!
-