How to open multiple web page links at same time?

What I’m trying to do

I have notes that have multiple links to web pages and I would like to open all the links in a note at the same time.

Things I have tried

I have tried to select all the links and right click but it doesn’t open any options with something like “Open all”.

Right now, opening multiple links from obsidian is time consuming since every time I open a single link it redirects me to the web page without not even giving the option to stay on the note.

Thank you

Meta-bind plugin may help.

Here’s an example from Inline JS - Meta Bind Docs (remember to set meta-bind-button as language in use).

style: primary
label: Greet the World
action:
  type: inlineJS
  code: "console.log('Hello World!');"

Here’s a button to open three URLs: Google, Youtube and Obsidian:

style: primary
label: Open multiple URLs
actions:
  - type: inlineJS
    code: |-
      let urls = [
        `https://www.google.com`, `https://www.youtube.com`, `https://obsidian.md`
      ];
      urls.forEach(url => {
        window.open(url, '_blank');  // open in new tab
      });

If you have a Title property in metadata, here’s my usage for a one-click academic search:

style: primary
label: Search
actions:
  - type: inlineJS
    code: |-
      let title = this.context.metadata.frontmatter.Title;
      let urls = [
        `https://www.google.com/search?q=${encodeURIComponent("site:arxiv.org" + " " + title)}`,
        `https://www.dblp.org/search?q=${encodeURIComponent(title)}`,
        `https://scholar.google.com/scholar?q=${encodeURIComponent(title)}`,
        `https://www.semanticscholar.org/search?q=${encodeURIComponent(title)}`,
        `https://www.google.com/search?q=${encodeURIComponent("site:openreview.net" + " " + title)}`,
        `https://www.google.com/search?q=${encodeURIComponent(title)}`,
      ];
      urls.forEach(url => {
        window.open(url, '_blank');  // open in new tab
      });
3 Likes

Same thing but open URL’s within Obsidian in Surfing browser tabs (will only work on PC):

style: primary
label: Search
actions:
  - type: inlineJS
    code: |-
      let title = this.context.metadata.frontmatter.Title;
      let urls = [
        `https://www.google.com/search?q=${encodeURIComponent("site:arxiv.org " + title)}`,
        `https://www.dblp.org/search?q=${encodeURIComponent(title)}`,
        `https://scholar.google.com/scholar?q=${encodeURIComponent(title)}`,
        `https://www.semanticscholar.org/search?q=${encodeURIComponent(title)}`,
        `https://www.google.com/search?q=${encodeURIComponent("site:openreview.net " + title)}`,
        `https://www.google.com/search?q=${encodeURIComponent(title)}`,
      ];

      urls.forEach(url => {
        const surfingView = app.workspace.getLeavesOfType("surfing-view").find(item => item.view);
        if (surfingView) {
          // Create a new tab for each URL
          surfingView.view.webviewEl.executeJavaScript(`
            window.open("${url}", "_blank");
          `, true);
        } else {
          new Notice("Surfing view not found. Open at least one Surfing tab to make it work.");
        }
      });
  • Currently needs at least one Surfing tab to be open to work…
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.