Skip to content

Commit

Permalink
adiciona InspectWP e Siteliner
Browse files Browse the repository at this point in the history
  • Loading branch information
claromes committed Sep 16, 2024
1 parent 19a47f2 commit b55efe1
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Acesse facilmente ferramentas de análise de web performance através do menu de
- [PageSpeed](https://pagespeed.web.dev/)
- [BuiltWith](https://builtwith.com/)
- [Yellow Lab Tools](https://yellowlab.tools/)
- [InspectWP](https://inspectwp.com/en)
- [Siteliner](https://www.siteliner.com/)
- [Image Analysis Tool by Cloudinary](https://webspeedtest.cloudinary.com/)
- [W3C Markup Validation Service](https://validator.w3.org/)

Expand Down
62 changes: 62 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ chrome.runtime.onInstalled.addListener(() => {
{ id: "PageSpeed", title: "PageSpeed" },
{ id: "BuiltWith", title: "BuiltWith" },
{ id: "Yellow", title: "Yellow Lab Tools" },
{ id: "InspectWP", title: "InspectWP" },
{ id: "Siteliner", title: "Siteliner" },
{ id: "Cloudinary", title: "Image Analysis Tool by Cloudinary" },
{ id: "W3C", title: "W3C Markup Validation Service" },
];
Expand All @@ -23,6 +25,8 @@ chrome.contextMenus.onClicked.addListener((info, tab) => {
)}`,
BuiltWith: `https://builtwith.com/?${encodeURIComponent(tab.url)}`,
Yellow: "https://yellowlab.tools/api/runs",
InspectWP: "https://inspectwp.com/en",
Siteliner: "https://www.siteliner.com/",
Cloudinary: "https://webspeedtest-api.cloudinary.com/test/run",
W3C: `https://validator.w3.org/nu/?doc=${encodeURIComponent(tab.url)}`,
};
Expand Down Expand Up @@ -81,6 +85,64 @@ chrome.contextMenus.onClicked.addListener((info, tab) => {
}

sendPostRequestYellow(tab.url);
} else if (info.menuItemId === "InspectWP") {
try {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
const activeTab = tabs[0];
const activeTabUrl = activeTab.url;

chrome.tabs.create({ url: siteUrls.InspectWP }, (newTab) => {
chrome.tabs.onUpdated.addListener(function onUpdated(
tabId,
changeInfo
) {
if (tabId === newTab.id && changeInfo.status === "complete") {
chrome.scripting.executeScript({
target: { tabId: newTab.id },
func: (url) => {
document.getElementById(
"inspectwp-checker-form-url-input"
).value = url;
document.querySelector("div.input-group button").click();
},
args: [activeTabUrl],
});
chrome.tabs.onUpdated.removeListener(onUpdated);
}
});
});
});
} catch (error) {
console.error("Erro ao enviar URL para InspectWP:", error);
}
} else if (info.menuItemId === "Siteliner") {
try {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
const activeTab = tabs[0];
const activeTabUrl = activeTab.url;

chrome.tabs.create({ url: siteUrls.Siteliner }, (newTab) => {
chrome.tabs.onUpdated.addListener(function onUpdated(
tabId,
changeInfo
) {
if (tabId === newTab.id && changeInfo.status === "complete") {
chrome.scripting.executeScript({
target: { tabId: newTab.id },
func: (url) => {
document.getElementById("field-domain").value = url;
document.getElementById("button-check-new").click();
},
args: [activeTabUrl],
});
chrome.tabs.onUpdated.removeListener(onUpdated);
}
});
});
});
} catch (error) {
console.error("Erro ao enviar URL para Siteliner:", error);
}
} else if (siteUrls[info.menuItemId]) {
chrome.tabs.create({ url: siteUrls[info.menuItemId] });
}
Expand Down
8 changes: 7 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
"author": "Célere",
"permissions": [
"contextMenus",
"tabs"
"tabs",
"activeTab",
"scripting"
],
"host_permissions": [
"https://www.siteliner.com/*",
"https://inspectwp.com/en/*"
],
"background": {
"service_worker": "background.js"
Expand Down

0 comments on commit b55efe1

Please sign in to comment.