Open tiddlers through monitoring another tiddler text field

I try to explain my aim here which might be confusing and/or out of scope for Tiddlywiki.

My TW is configured with Node.js under Windows 11 and managed my reference with refnotes plugins.

I am developing a Chrome Extension to add a toolbar over publication page through matching doi if I have managed it in TW. See example below for icons of TW, and links to Google Scholar and Scopus in the right top corner.

I understand I can create a permalink to a tiddler TiddlyWiki in a new tab. However, I prefer to open it in the current story river.

After googling, I found it is impossible to active another tab (i.e. Tiddlywiki Tab) from Chrome Extension.

Now my idea is to POST tiddler title, which I want to open, into a new tiddler (e.g. $:/from-chrome-extension) from my Chrome Extension, then monitor this tiddler and open them in the story river in TW.

So my question is it is possible to develop in TW for these requirements.

  • monitor the text field in a tiddler (e.g. $:/from-chrome-extension)
  • parse text field as a list of tiddlers
  • open it in the story river if it is not opening
  • switch to it if it is already opening

Hope it makes sense. Thanks for any advices.

1 Like

Hi @Zheng_Bangyou perhaps the easiest approach would be for your Chrome extension to PUT an update to $:/StoryList as well as the new tiddler.

The missing ingredient is that by default the $:/StoryList tiddler is not synced from the client to the server. To fix that, set the tiddler $:/config/SyncSystemTiddlersFromServer to yes.

1 Like

Thanks @jeremyruston, I will try your method.

@jeremyruston It seems this method is not working. I cannot figure out how to skip CORS checking for PUT in js with Chrome Extension (although GET is working now) .

But I do PUT changes to list field in the $:/StoryList from R and setup $:/config/SyncSystemTiddlersFromServer to yes. However, it seems the system tiddler does not sync from server to client.

I am not sure if I understand what you are trying to do but you can make any tab active via a chrome extension using this call:

chrome.tabs.update(tab.id,{active:true});

you can focus a window by:

chrome.windows.update(tab.windowId, {focused:true});

The method requires to get tabID which create by the extension. It is not possible to retrieve tabID and windowsID if it opens from other methods.

If your tw is in the browser and you know the url you could used

    chrome.tabs.query ({url:myurl},function(tabs){
		chrome.windows.update(tabs[0].windowId, {focused:true});
		chrome.tabs.update(tabs[0].id,{active:true});
    })
1 Like

Thanks @buggyj. I learned from your tiddlyclip plugin and Chrome Extension Message Passing. Now I can send the tiddler tiddler from other pages into my local tiddlywiki.

This is my scripts in the content_page for TW


chrome.runtime.onMessage.addListener(
  function(request, sender, sendResponse) {
    if (request.from == "worker") {
        console.log(request.tiddler);
    }
  }
);

The last step I want is to open this tiddler in the story river. Do you implement it in TiddlyClip extension? Cannot find any clues from source codes.

I guess if I get the $tw variable, then can call TW function to open a tiddler.

@Zheng_Bangyou There is not a function to open a tiddler in the story, probably the simplest way to open the tiddler in the story is to add its title to the list field of $:/StoryList

Tiddlyclip has a non-visible widget on the page that sends messages to the
$navigator widget to open tiddlers.

1 Like

Thanks @buggyj for your suggestion. I implemented a custom event to open tiddlers.

To open a tiddler in the story is to navigate to it.