ZoteroBib as a chrome extension

This amazing tool must exists as a chrome extension. Similar to how the extension "Bibtex entry from url" works [1].


[1] https://chrome.google.com/webstore/detail/bibtex-entry-from-url/mgpmgkhhbjgkpnanlmlhibjfgpdpgjec
  • What are you actually trying to do? Just generate citations from the current page?

    If anything that would just be incorporated into the Zotero Connector, but it's a bit of a questionable concept, since metadata isn't perfect and sometimes has to be adjusted in order to generate correct citations. So while the Connector could in theory let you edit metadata without saving, you'd have to do that every time you generated a citation for a given URL. It would usually make more sense to just save to Zotero, tweak metadata as necessary one time, and use Quick Copy to copy to the clipboard in your desired format.
  • I think that an extension is a good idea, you can of course edit the zoterobib display as usual. So there is no real difference except it saves you the trouble of opening the zoterobib website and copying the current URL and pasting it into the zoterobib tab. Several steps in one click. I know someone who could write that extension in 30 minutes max.
  • edited July 3, 2022
    Streamlining the process of adding to zbib can be done with a bookmarklet, for example like this one:

    javascript:window.location = `https://zbib.org/import?q=${(window.getSelection().toString() || window.location.toString()).trim()}`

    Copy the code and save it as bookmark. Afterwards when visiting a page you can just select an identifier in text (URL/DOI/ISBN etc.) and click on the bookmarklet to import it to into zbib, or, if nothing is selected, it will just import current URL.
  • Thanks for the reply. I tried it in Chrome and Edge and it did not work in either, not sure why. I think bookmarklets have their place but a browser extension would work better for most people. I'll see if I can post one in the next few weeks. I will put Unofficial Zoterobib in the description, so it's clear it's not from the Zotero group.
  • There were extra quotes at the end of what @tnajdek posted — I've removed them. It works perfectly fine in Chrome. There's really no need for this to be an extension — this is the entire logic.
  • Thanks, that now works. It does look like a valid option. It doesn't resolve if the zoterobib tab is already open, and it replaces the current tab with zoterobib, so the current article goes away (which I'm not sure most people would want, so I'll ask a few people). Appreciate the responses...
  • You can use window.open(…) instead of window.location = … to open it in a new tab:

    javascript:window.open(`https://zbib.org/import?q=${(window.getSelection().toString() || window.location.toString()).trim()}`)
  • OK great we are just about to a home run.... Thanks! I did open another post on the 10-item limit as it stops working after 10 cites and requires you to delete some prior items as opposed to a rolling 10 etc.
  • edited July 4, 2022
    There's no such limit, but we can continue that there.
  • This is definitely something that I'd use all the time i.e. the ability to create a citation without having to first save to Zotero, or need to have Zoterbib open. I share stuff all the time, and in my context as an academic, I like to share with the additional metadata included in a citation.

    I know that metadata is hard and the citation may therefore have issues with missing detail. However, I'm not looking for something to add to a paper. I just need something that pulls out what Zoterobib is doing, without having to go through Zoterobib.

    When I try using the suggested option here, the new Zoterobib page opens in a new tab, with the citation correctly displayed. However, the original page reloads without any content, with only the words "[object Window]" displayed.

    The ability to right-click on the Zotero connector, and choose "Generate citation", which shows up in a notification that I can copy, would save me so much time.

    The MyBib citation generator Chrome extension (https://chrome.google.com/webstore/detail/mybib-free-citation-gener/phidhnmbkbkbkbknhldmpmnacgicphkf) is a bit like what I'm looking for.
  • I'm interested in something similar to what @mrowedr is suggesting. I'd like to be able to send the current browser tab to Zotero/Zbib and get the default response copied to my clipboard. Has anyone worked on something similar? If not, I'm happy to try hacking together a prototype.
  • OK! Here's a hacky script in Autohotkey v2 that gets about half-way there. If you press Alt+Shift+B, It will look up whatever text is highlighted.

    ; URL encoding helpers
    ; Thanks to just me
    ; https://www.autohotkey.com/boards/viewtopic.php?p=583469#p583469
    UriEncode(Url, Flags := 0x000C3000) {
    Local CC := 4096, Esc := "", Result := ""
    Loop
    VarSetStrCapacity(&Esc, CC), Result := DllCall("Shlwapi.dll\UrlEscapeW", "Str", Url, "Str", &Esc, "UIntP", &CC, "UInt", Flags, "UInt")
    Until Result != 0x80004003 ; E_POINTER
    Return Esc
    }

    ; Hotkey to import highlighted text to ZoteroBib (Alt+Shift+B)
    +!b::
    {
    ; Store the original clipboard content
    originalClipboard := A_Clipboard

    ; Copy the selected text
    Send("^c")
    Sleep(200) ; Brief pause to ensure copy completes

    ; Retrieve the copied text
    copiedText := A_Clipboard

    ; Construct ZoteroBib import URL with URL-encoded text
    zoteroImportURL := "https://zbib.org/import?q=" . UriEncode(copiedText)

    ; Open in default browser
    Run(zoteroImportURL)

    ; Restore the original clipboard content
    A_Clipboard := originalClipboard
    }
Sign In or Register to comment.