DOI translator does not pick up DOIs

87 views
Skip to first unread message

Emiliano Heyns

unread,
Oct 2, 2024, 5:44:27 PM10/2/24
to zotero-dev
I have a webpage (https://coda.io/d/New-PubMed-Coda-Test-with-Formulas-Table_dyJPuKfmm8r/Production-PubMed-Queries-with-Formulas-Table_su6tqRzU#_lu_mO6N_) that has DOIs on it, but I think the Embedded Metadata translator gets there first and doesn't offer the DOI import. Is there a way I can force the DOIs to be picked up by detectWeb/doWeb?

Abe Jellinek

unread,
Oct 2, 2024, 5:56:21 PM10/2/24
to zoter...@googlegroups.com
From your site’s end, you mean, without modifying either translator? No. You can right-click the Zotero Connector toolbar button and choose DOI manually, though.

On Oct 2, 2024, at 5:44 PM, Emiliano Heyns <emilian...@iris-advies.com> wrote:

I have a webpage (https://coda.io/d/New-PubMed-Coda-Test-with-Formulas-Table_dyJPuKfmm8r/Production-PubMed-Queries-with-Formulas-Table_su6tqRzU#_lu_mO6N_) that has DOIs on it, but I think the Embedded Metadata translator gets there first and doesn't offer the DOI import. Is there a way I can force the DOIs to be picked up by detectWeb/doWeb?

--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zotero-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zotero-dev/a4fc1bf5-dbef-42f9-bc9c-daf2f3c624dbn%40googlegroups.com.

Emiliano Heyns

unread,
Oct 2, 2024, 8:02:23 PM10/2/24
to zotero-dev
I don't get that option. I only see Embedded Metadata when I right click the button. Having DOI import by right click would be fine. 

You received this message because you are subscribed to a topic in the Google Groups "zotero-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zotero-dev/f2aX08GO7x0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zotero-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zotero-dev/FAE76B7B-2F67-4EE9-81EF-E3EA014FFA5C%40berkeley.edu.

Emiliano Heyns

unread,
Oct 4, 2024, 8:21:02 AM10/4/24
to zotero-dev
This page loads its data async -- it may be that the DOI translator has ran before any of the DOIs are on the page. Is there a way to delay the page search? I don't mind making a specialized translator; for detectWeb I could just have it return `true` for coda URLs, but `doWeb` would still have to hold off parsing until the data has loaded, and I don't see any samples of async doWeb handlers.

fcheslack

unread,
Oct 4, 2024, 8:53:25 AM10/4/24
to zoter...@googlegroups.com
After the data loads you can trigger an event to tell Zotero to run detection again.



Abe Jellinek

unread,
Oct 4, 2024, 10:43:08 AM10/4/24
to zoter...@googlegroups.com
And if you don’t have control over the page's JavaScript, you could write a translator for your own use that calls monitorDOMChanges() in detectWeb(). (We wouldn’t be able to merge that into zotero/translators, but it doesn’t sound like that’s what you need here.)

Emiliano Heyns

unread,
Oct 4, 2024, 11:03:42 AM10/4/24
to zotero-dev
Thank you -- perfect!

Emiliano Heyns

unread,
Oct 7, 2024, 3:44:15 PM10/7/24
to zotero-dev
Still not fully working unfortunately. It picks up two now while there are several more on the page. How long does the translator keep looking for changes? I've also just added a 10s wait to doWeb and it's still only picking up a fraction.

Emiliano Heyns

unread,
Oct 7, 2024, 3:45:09 PM10/7/24
to zotero-dev
I cannot add javascript to the page, so I'll have to do this in the translator.

Abe Jellinek

unread,
Oct 7, 2024, 5:09:30 PM10/7/24
to zoter...@googlegroups.com
It stops re-calling detectWeb once that method returns something, so keep calling monitorDOMChanges and returning false until everything you want is loaded.

Emiliano Heyns

unread,
Oct 8, 2024, 3:25:58 AM10/8/24
to zotero-dev
I don't know up-front how many DOIs there will be. If I use this

const started = Date.now()

function detectWeb(doc, url) {
  if ((Date.now() - started) < 5000) {
    Zotero.monitorDOMChanges(doc.body)
    return false
  }
  // Blacklist the advertising iframe in ScienceDirect guest mode:
  // http://www.sciencedirect.com/science/advertisement/options/num/264322/mainCat/general/cat/general/acct/...
  // This can be removed from blacklist when 5c324134c636a3a3e0432f1d2f277a6bc2717c2a hits all clients (Z 3.0+)
  const blacklistRe = /^https?:\/\/[^/]*(?:google\.com|sciencedirect\.com\/science\/advertisement\/)/i;
  if (blacklistRe.test(url)) {
      return false;
  }

  let doiOrDOIs = getDOIs(doc, url);
  if (Array.isArray(doiOrDOIs)) {
      return doiOrDOIs.length ? "multiple" : false;
  }

  return "journalArticle"; // A decent guess
}

I take it that will run the risk of returning false if the last DOM update is before those 5 seconds, regardless of whether DOIs are on the page.

What I'd really like to achieve is "if something changed in the DOM in the past second, try again by calling Zotero.monitorDOMChanges and returning false, else run the rest of the regular body of detectWeb". 



Reply all
Reply to author
Forward
0 new messages