`;
- abstractH2 = queryAll("h2").find((h) => h.innerText.trim() === "Abstract");
+ const abstractH2 = queryAll("h2").find((h) => h.innerText.trim() === "Abstract");
if (!abstractH2) {
log("Missing 'Abstract' h2 title on HuggingFace paper page.");
+ return;
}
const authorDiv = abstractH2.parentElement.previousElementSibling;
log("Adding venue to HuggingFace paper page.");
@@ -852,7 +857,7 @@ const updateCompleteSecretHTML = (paper) => {
.querySelector("head")
.insertAdjacentHTML(
"beforeend",
- /*html*/ ``,
+ /*html*/ ``,
);
}
}, 50);
diff --git a/src/options/options.js b/src/options/options.js
index 3611fce4..1dea8bf0 100644
--- a/src/options/options.js
+++ b/src/options/options.js
@@ -32,6 +32,7 @@ import {
cleanPapers,
sendMessageToBackground,
parseTags,
+ escapeHtml,
} from "@pmu/functions.js";
import {
makePaper,
@@ -140,7 +141,7 @@ const handleSelectImportJson = () => {
findEl({ element: "import-json-papers-button" }).disabled = false;
};
-const validateImportPaper = (p) => {
+const validateImportPaper = (p, i) => {
if (typeof p === "string") {
if (!isValidHttpUrl(p)) {
alert(`${p} (entry ${i}) is not a valid URL`);
@@ -213,7 +214,7 @@ const handleParseImportJson = async (e) => {
throw new Error("The JSON file must contain a *list* of papers");
}
for (const [i, p] of papersToParse.entries()) {
- if (!validateImportPaper(p)) {
+ if (!validateImportPaper(p, i)) {
return;
}
}
@@ -248,7 +249,7 @@ const handleParseImportJson = async (e) => {
if (!Object.values(is).some((i) => i)) {
feedback.innerHTML += `
[${
i + 1
- }] × Error: ${url} does not come from a known source
`;
+ }] × Error: ${escapeHtml(url)} does not come from a known source`;
warn("Aborting.");
} else {
let paper;
@@ -266,12 +267,12 @@ const handleParseImportJson = async (e) => {
if (exists) {
feedback.innerHTML += `
[${
i + 1
- }] × Warning: ${url} already exists and has been ignored
`;
+ }] × Warning: ${escapeHtml(url)} already exists and has been ignored`;
warn("Aborting.");
} else {
feedback.innerHTML += `
[${
i + 1
- }] ✔ ${url} has been successfully added to your Memory!
`;
+ }] ✔ ${escapeHtml(url)} has been successfully added to your Memory!`;
}
}
} catch (error) {
@@ -279,7 +280,7 @@ const handleParseImportJson = async (e) => {
warn("Aborting.");
feedback.innerHTML += `
[${
i + 1
- }] × Error: ${url} (open the JavaScript Console for more info)
`;
+ }] × Error: ${escapeHtml(url)} (open the JavaScript Console for more info)`;
}
}
await pushToRemote();
@@ -348,13 +349,13 @@ const getAutoTagHTML = (at) => {
return /*html*/ `
-
+
-
+
-
+
@@ -496,14 +497,14 @@ const addPreprintUpdate = (update) => {
for (const [k, v] of Object.entries(update)) {
if (k !== "paper" && k !== "bibtex") {
if (v) {
- contents.push(`${k}:${v}`);
+ contents.push(`${escapeHtml(k)}:${escapeHtml(v)}`);
}
}
}
contents = contents.join(" ");
const html = /*html*/ `