Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0c7ee64
Update README.md
jruns May 14, 2025
8f6832f
Update README.md
jruns May 14, 2025
877b8a0
2025 upgrades for Firefox (#1)
jruns May 14, 2025
ef1ae24
Add package.json for web-ext firefox builds
jruns May 14, 2025
ccef45f
Update gitignore
jruns May 14, 2025
3b9c4f0
Update README
jruns May 14, 2025
c73868a
Update README.md with Chrome installation instructions
jruns May 14, 2025
19e6a1d
Undo icons folder move
jruns May 28, 2025
6182d71
Revert manifest changes from original repo
jruns May 28, 2025
d9930c6
Copy my individual changes to original background.js
jruns May 28, 2025
7cef4cc
Revert repo README changes
jruns May 28, 2025
a4ab13c
Update icon by tabId so that multiple windows can maintain their own …
jruns May 28, 2025
66eec40
Revert README to fork version
jruns May 28, 2025
c3a8439
Support switching windows, and remove unneeded event listeners
jruns May 28, 2025
afe2235
Update comment
jruns May 28, 2025
774ec70
Set icon title when WordPress is detected
jruns May 31, 2025
e5c562f
Added back onActivated listener
jruns May 31, 2025
0adef64
Change version for local testing
jruns May 31, 2025
b1fba76
Remove xmlrpc.php check
jruns Jun 1, 2025
28b3de0
Bump version for testing
jruns Jun 1, 2025
fa9b5c0
Remove about:newtab query
jruns Jun 1, 2025
5033bff
Update version
jruns Jun 9, 2025
487ce7c
Upgrade to manifest v3 and bump version
jruns Jun 10, 2025
e8bb308
Add min versions based on support for scripts and service_worker in b…
jruns Jun 10, 2025
34ff377
Temp version for local testing
jruns Jun 10, 2025
76a5113
Update gecko id
jruns Jun 10, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.zip
web-ext-artifacts
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"scripts": {
"build": "web-ext build --filename wordpress-detector.zip --overwrite-dest --source-dir ./src/",
"sign": "web-ext sign --source-dir ./src/",
"start:firefox": "web-ext run --source-dir ./src/"
}
}
36 changes: 19 additions & 17 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,38 @@
// terms we will search in <head> to detect WordPress
const clues = ["wp-content", "wp-includes"]

// reset icon
updateIcon(false)

// updates the icon in the toolbar
const updateIcon = (state) => {
const updateIcon = (state, tabId = null) => {
const path = state ? "icon_on_32.png" : "icon_off_32.png";
chrome.browserAction.setIcon({ path })
const title = state ? "WordPress Detector (detected)" : "WordPress Detector (not detected)";
chrome.action.setIcon({ path, tabId })
chrome.action.setTitle({ title, tabId })
}

// detect wordpress in a pages <head>
const detectWordPress = (head) => {
updateIcon(head && head != null && head !== "" && clues.some(v => head.includes(v)))
const detectWordPress = (head, tabId) => {
if ( typeof head !== "undefined" ) {
const state = head && head != null && head !== "" && clues.some(v => head.includes(v))
updateIcon( state, tabId )
}
}

const onTabUpdate = () => {
const onTabUpdate = (activeInfo) => {
// reset
updateIcon(false)
updateIcon(false, activeInfo.tabId)

// get current tab's <head> and detect WordPress
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { text: "send_head_inner" }, function (response) {
detectWordPress(response)
// get each window's active tab's <head> and detect WordPress
chrome.tabs.query({ active: true, windowType: 'normal', url: ['*://*/*'] }, function (tabs) {
tabs.forEach( function( tab, index, arr ) {
const tabId = tab.id;
chrome.tabs.sendMessage(tabId, { tabId: tabId, text: "send_head_inner" }, function (response) {
detectWordPress( response?.response, response?.tabId )
});
});
});
}

// listen for tab updates
chrome.tabs.onActivated.addListener(onTabUpdate)
chrome.tabs.onUpdated.addListener(onTabUpdate)
chrome.tabs.onCreated.addListener(onTabUpdate)
chrome.windows.onFocusChanged.addListener(onTabUpdate)
chrome.tabs.onRemoved.addListener(onTabUpdate)
chrome.tabs.onReplaced.addListener(onTabUpdate)
chrome.windows.onFocusChanged.addListener(onTabUpdate)
2 changes: 1 addition & 1 deletion src/content.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
if (msg.text === 'send_head_inner') {
sendResponse(document.head.innerHTML)
sendResponse( { response: document.head.innerHTML, tabId: msg.tabId } )
}
});
Binary file modified src/icon_off_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/icon_off_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/icon_off_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/icon_off_48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
25 changes: 19 additions & 6 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
{
"name": "WordPress Detector",
"author": "bensaine",
"version": "1.0",
"version": "1.0.3",
"description": "WordPress Detector will detect instantly if the site in your current tab is made using WordPress!",
"permissions": ["activeTab"],
"minimum_chrome_version": "121",
"browser_specific_settings": {
"gecko": {
"id": "{21a16015-26a5-4449-92ae-633e2b960be7}",
"strict_min_version": "121.0"
},
"gecko_android": {
"strict_min_version": "121.0"
},
"safari": {
"strict_min_version": "15.4"
}
},
"permissions": ["activeTab", "tabs"],
"background": {
"scripts": ["background.js"],
"persistent": false
"service_worker": "background.js",
"scripts": ["background.js"]
},
"content_scripts": [
{
Expand All @@ -20,8 +33,8 @@
"48": "icon_48.png",
"128": "icon_128.png"
},
"manifest_version": 2,
"browser_action": {
"manifest_version": 3,
"action": {
"default_icon": "icon_off_32.png",
"default_title": "WordPress Detector"
}
Expand Down
Binary file removed wordpress-detector.zip
Binary file not shown.