From 7c4fedb910a2a36ce3e884ed97272b02e92a9be7 Mon Sep 17 00:00:00 2001 From: Fancy Date: Wed, 6 Dec 2023 16:19:09 +0800 Subject: [PATCH 1/2] bugfix: add null check --- Twine by SwiftGG plugin/content_script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Twine by SwiftGG plugin/content_script.js b/Twine by SwiftGG plugin/content_script.js index e835b1a..942f346 100644 --- a/Twine by SwiftGG plugin/content_script.js +++ b/Twine by SwiftGG plugin/content_script.js @@ -142,8 +142,8 @@ function updateAHerfToAbsolutURL() { function addTitleNode() { let title = document.querySelector("div.headline h1"); if (!title) { return; } - let titleText = json[title.innerText.trim()].zh; - if (!titleText || titleText === "") { + let titleText = json[title.innerText.trim()]?.zh; + if (!titleText || !titleText || titleText === "") { return; } let newNode = document.createElement("h3"); From 0360d20ce137b260da0988a740a0ca63d9c1a7f9 Mon Sep 17 00:00:00 2001 From: Fancy Date: Wed, 6 Dec 2023 16:24:00 +0800 Subject: [PATCH 2/2] bugfix: remove duplicate check --- Twine by SwiftGG plugin/content_script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Twine by SwiftGG plugin/content_script.js b/Twine by SwiftGG plugin/content_script.js index 942f346..fd69f3e 100644 --- a/Twine by SwiftGG plugin/content_script.js +++ b/Twine by SwiftGG plugin/content_script.js @@ -143,7 +143,7 @@ function addTitleNode() { let title = document.querySelector("div.headline h1"); if (!title) { return; } let titleText = json[title.innerText.trim()]?.zh; - if (!titleText || !titleText || titleText === "") { + if (!titleText || titleText === "") { return; } let newNode = document.createElement("h3");