javascript: (function () { function fetchBibTeX(url) { fetch(url) .then((response) => response.json()) .then((data) => { const authors = data.authorships .map((author) => author.raw_author_name) .join(" and "); const title = data.title; const journal = data.primary_location.source.display_name; const year = data.publication_year; const volume = data.biblio.volume; const pages = `${data.biblio.first_page}--${data.biblio.last_page}`; const doi = data.ids.doi.split("/").pop(); const bibtex = ` @article{${authors.replace(/ /g, "")}${year}, author = {${authors}}, title = {${title}}, journal = {${journal}}, year = {${year}}, volume = {${volume}}, pages = {${pages}}, doi = {${doi}} }`; navigator.clipboard.writeText(bibtex).then( function () { alert("BibTeX entry copied to clipboard"); }, function () { prompt( "Failed to copy BibTeX entry to clipboard. You can copy it manually from here:", bibtex ); } ); }); } const currentUrl = window.location.href; const openAlexUrlPattern = /https:\/\/api\.openalex\.org\/works\/(\w+)/; const match = openAlexUrlPattern.exec(currentUrl); if (match) { fetchBibTeX(currentUrl); } else { const workId = prompt("Enter the OpenAlex Work ID:"); if (workId) { const url = `https://api.openalex.org/works/${workId}`; fetchBibTeX(url); } } })();