Open URL using specific Chrome Profile or a specific browser including DT3

Hello,

I use multiple Chrome Profiles and I wanted to have a web page popup from time to time to remind me to check something important.

I was playing with this reminder in DT3 and realized today that it opens in the active profile (which happened to be a profile were I don’t want the URL to be opened). So I have to rethink this… Looking for some ideas/help.

Annotations and Reminders Inspector:
image

The reminder opens the URL that is listed in in the Info Inspector here:
image

I saw that it is possible to pass a Chrome Profile, but I don’t think there’s a way for me to do this with the built-in tools, meaning I would have to use a script and a change the trigger item:

image

  1. If I wanted the link to open as a new tab in DT3, how is that best accomplished? (This would eliminate my need to script the Chrome profile)
  2. If opening in DT3 requires a script, then I suppose it becomes a 50/50 to pick a browser and a URL + profile as needed.

Any other methods/ideas I should consider? I want the page to open to capture some information on it regularly, so I’m not looking to just get a notification type alert. I’d like something closer to an automatic web archive capture but since I only want to capture or know if something has changed on the page, perhaps there’s an entirely better solution and I just am too new with DT3 to imagine it.

Thank you.

I’m probably biased, but I’d use a regularly running script to do that. Although I’m not sure if you only want to capture a part of the page (or rather retrieve some changing values from it, like stock values) or in fact save the whole page if something has changed. This “something has changed” condition is a bit vague, too: You’d need a copy of the page to compare with the current one and define what “change” means for you. E.g.: Is another font relevant or a new entry in the navigation or only a different value of a paragraph/table cell/whatever?

Very specifically, I have a community thread on youtube and I can’t find a way to get notifications for posts. Videos posts on youtube are fine, but the comments in the community section seem to have no trigger on OSx, iOS, or PC.

And yes, I just want to capture the last post, not the entire page (and I am not the page owner, nor am I worried about replies to the posts).

So in DT, you just want the latest post? Or do you want all posts in DT and add the latest one to them when/if it arrives?

What I’d try to do:

  • have a look at the relevant HTML document in my favourite browser’s developer console
  • figure out how the comments are represented in the DOM
  • write a tiny script that (using querySelector or querySelectorAll) retrieves the comments’ HTML nodes
  • go over these nodes with the usual tools to analyze their content and act accordingly.

AFAIK, this is possible from within DT since you can run JavaScript on a HTML document loaded in its viewer (or at least I seem to remember having seen something like that recently in the forum).

In any case, while that should be possible, it is not a robust approach. Youtube might change the DOM in their Web pages at any time, which might require a change to the script.

May I ask why you’d want to use a document management system to inform you about posts on a Youtube page? To me, it seems to be jumping through a lot of loops.

1 Like

Each post tends to have some important information for the subject I am following.
So I copy the text and save an image of it and keep it in my DT3 database for this subject.

I should add that

  1. Youtube doesn’t show dates after the posts become old, so you are stuck with “1 month ago” style descriptions if you want to find something
  2. If you try to go back multiple years it takes so much time to load messages on the web.
  3. You don’t get any of the AI features with DT3 if you leave the info on YouTube and I want these posts to be integrated with my own notes so they come up in my searches.

There’s some information on how this could be done to be found here

Which led me to this sample script:

(() => {
  const app = Application("DEVONthink 3");
  const window = app.thinkWindows()[0];
  window.url = "https://bru6.de/jxa"; // replace with your URL
  const title = app.doJavaScript("document.title", {in: window.currentTab()});
  console.log(title);
})()

It’s trivial stuff, of course. But as you can see, you can run JavaScript code on any URL you’re interested in: DT loads it in its thinkWindow where it’s available to all DOM methods.

I’d probably try to return some kind of JSON from the JavaScript run on the web page and then post-process this before adding anything to DT. But that’s of course a matter of taste. The important thing to note here is that doJavaScript returns a string. I doubt that any other data type would work here, and since you have no access to the DOM outside of doJavaScript, you can’t retrieve DOM subtrees or anything like that to work with in DT.

@cgrunenberg: According to the function library, doJavaScript expects a thinkWindow with in. At least over here, that didn’t work, I had to pass in the window’s tab. I’m not sure if that’s a glitch in my mind, in the documentation or in the underlying scripting support.

Very interesting… So this does open the web page in the current window every hour.

image

Has some interesting behavior.
For example, I was editing a Markdown document and the macro ran.
Inside my preview window was suddenly displayed a washed out version of the web page (formatting stripped). Quite interesting.

I’ll play with the script some more. Thanks for getting me started.

Instead of setting the window.url directly, you could use
const tab = app.openTabFor({url: "..."})
That will open a new window with the URL. In that case, use the tab as value for in in the call doJavaScript. After you’ve done whatever you need to do with the HTML document. call tab.close() on it.

Note I didn’t check this last part, maybe some experimenting is in order there.

1 Like

That works perfectly.
Thank you.
Final script:

function performreminder(record) {
	var app = Application("DEVONthink 3");
	app.includeStandardAdditions = true;
    const window = app.thinkWindows()[0];
    const tab = app.openTabFor({url: "https://www.youtube.com/c/[youryoutubechannel]/community"}); // replace with your URL
    const title = app.doJavaScript("document.title", {in: tab()});
}

This simply gives me a new window with the last saved URL from my DT3 database, but that’s fine. I hit refresh and I can see if anything new appears.

I can learn more from here and perhaps start checking the page for information.

Thank you for getting me started with launching some JavaScript inside DEVONthink. Helps to have a framework of how to get started.

Very good thing that I saved my script here, because I just learned that if you switch the reminder alarm menu from javascript to something else, the javascript contained in the menu is lost if the document is closed/reopened.

Where it goes, I do not know, but I tested:

  1. Script is entered and working
  2. Change Alarm to Launch URL
  3. Test that this works (doc must be saved) which apparently deletes any attached scripts rather than leaving them in the associated menu metadata.
  4. Change back to any of the script alarms and they are default.

After changing the alarm, I went to my Reminders group in the left panel and realized two things:

  1. My alarm wasn’t there.
  2. The Reminders group I had placed in Smart Rules
  3. The alarm wasn’t displaying because the Smart Rule was set to Documents only and didn’t consider that a group can have an alarm.

So, I fixed that by changing the smart rule to this:
image

Perhaps I did a tutorial to create a smart rule that plays a sound?
I think a smart group is all I need:
image

That seems to do the trick and shows me groups and documents that contain a reminder.
Perfect.

Does DT3 have a way to version these smart rules and groups? I’d like to see when I created the original and what changes I have made on which dates? Seems each rule/group should have a mini time machine to show me this history, right? Guess I’m so used to Google now after 15 years that I’m spoiled by having a history of every action…

But I really like that DT3 supports replicants. Google Drive used to have this, but apparently it confused everybody and they dropped it in favor of creating shortcuts. Not my favorite choice. So DT3 is now my #1 organizer. Kudos to DT3 for offering both tags and replicants and even keeping the folder idea with groups. It’s like they decided that all the ideas were great and why not keep them all. Great choice.

Maybe if I can just figure out how to version documents including smart rules and groups and tags automatically…

Does DT3 have a way to version these smart rules and groups? Seems each rule/group should have a mini time machine to show me this history, right?

Sorry but no, there is no versioning of smart rule unless you were exporting them manually as you worked on them.

So DT3 is now my #1 organizer. Kudos to DT3 for offering both tags and replicants and even keeping the folder idea with groups. It’s like they decided that all the ideas were great and why not keep them all. Great choice.

Thanks for the nice feedback.

Maybe if I can just figure out how to version documents including smart rules and groups and tags automatically…

I don’t recall anyone ever asking for versioning of non-document items.

1 Like