Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chrome/content.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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);
}

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;

Expand Down
4 changes: 2 additions & 2 deletions firefox/content.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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);
}

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;

Expand Down