From 60cca5817c8e7ca6fd5dd1aa05bcc53b158f9463 Mon Sep 17 00:00:00 2001 From: Photon-gjq <71842413+Photon-gjq@users.noreply.github.com> Date: Sun, 9 Jun 2024 11:41:05 +0800 Subject: [PATCH 1/2] Change the title fetch for the Chinese wiki pages. --- chrome/content.js | 2 +- firefox/content.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content.js b/chrome/content.js index 4be8a69..2f9f115 100644 --- a/chrome/content.js +++ b/chrome/content.js @@ -7,7 +7,7 @@ function isValidWikipediaArticle() { function sendArticleInfo() { if (isValidWikipediaArticle()) { - const title = document.querySelector('h1').innerText; + const title = document.querySelector('h1 > :first-child').innerText; const url = window.location.href; const parent = document.referrer.includes("wikipedia.org") && isValidWikipediaArticle(document.referrer) ? document.referrer : null; diff --git a/firefox/content.js b/firefox/content.js index 234c0ba..89623a0 100644 --- a/firefox/content.js +++ b/firefox/content.js @@ -7,7 +7,7 @@ function isValidWikipediaArticle() { function sendArticleInfo() { if (isValidWikipediaArticle()) { - const title = document.querySelector('h1').innerText; + const title = document.querySelector('h1 > :first-child').innerText; const url = window.location.href; const parent = document.referrer.includes("wikipedia.org") && isValidWikipediaArticle(document.referrer) ? document.referrer : null; From fc61323c5251e97f92f410e639e671aceb4de842 Mon Sep 17 00:00:00 2001 From: Photon-gjq <71842413+Photon-gjq@users.noreply.github.com> Date: Thu, 13 Jun 2024 00:25:11 +0800 Subject: [PATCH 2/2] Change the regular expression for domain name fetch --- chrome/content.js | 2 +- firefox/content.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content.js b/chrome/content.js index 2f9f115..ce958ca 100644 --- a/chrome/content.js +++ b/chrome/content.js @@ -1,7 +1,7 @@ function isValidWikipediaArticle() { // Check if the URL follows the typical pattern for Wikipedia articles // This regex matches the main article pages but excludes special pages, user pages, etc. - const urlRegex = /^https?:\/\/[a-z]+\.wikipedia\.org\/(?:wiki|zh-cn|zh-hk|zh-mo|zh-my|zh-sg|zh-tw)\/(?!Special:|User:|Wikipedia:|File:|MediaWiki:|Template:|Help:|Category:|Portal:|Draft:|TimedText:|Module:|Gadget:|Gadget_definition:|Education_Program:|Topic:|Book:|Special:Search|Special:RecentChanges).+/; + const urlRegex = /^https?:\/\/[a-z-]+\.wikipedia\.org\/(?:wiki|zh-cn|zh-hk|zh-mo|zh-my|zh-sg|zh-tw)\/(?!Special:|User:|Wikipedia:|File:|MediaWiki:|Template:|Help:|Category:|Portal:|Draft:|TimedText:|Module:|Gadget:|Gadget_definition:|Education_Program:|Topic:|Book:|Special:Search|Special:RecentChanges).+/; return urlRegex.test(window.location.href); } diff --git a/firefox/content.js b/firefox/content.js index 89623a0..eae00bb 100644 --- a/firefox/content.js +++ b/firefox/content.js @@ -1,7 +1,7 @@ function isValidWikipediaArticle() { // Check if the URL follows the typical pattern for Wikipedia articles // This regex matches the main article pages but excludes special pages, user pages, etc. - const urlRegex = /^https?:\/\/[a-z]+\.wikipedia\.org\/(?:wiki|zh-cn|zh-hk|zh-mo|zh-my|zh-sg|zh-tw)\/(?!Special:|User:|Wikipedia:|File:|MediaWiki:|Template:|Help:|Category:|Portal:|Draft:|TimedText:|Module:|Gadget:|Gadget_definition:|Education_Program:|Topic:|Book:|Special:Search|Special:RecentChanges).+/; + const urlRegex = /^https?:\/\/[a-z-]+\.wikipedia\.org\/(?:wiki|zh-cn|zh-hk|zh-mo|zh-my|zh-sg|zh-tw)\/(?!Special:|User:|Wikipedia:|File:|MediaWiki:|Template:|Help:|Category:|Portal:|Draft:|TimedText:|Module:|Gadget:|Gadget_definition:|Education_Program:|Topic:|Book:|Special:Search|Special:RecentChanges).+/; return urlRegex.test(window.location.href); }