Skip to content

Commit

Permalink
Merge pull request #1 from Celere-WP/v0.2
Browse files Browse the repository at this point in the history
v0.2
  • Loading branch information
claromes authored Sep 16, 2024
2 parents a585794 + a613375 commit 2059e2d
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 14 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Celeridade
# Célere Toolkit

Acesse PageSpeed, BuiltWith e Image Analysis Tool by Cloudinary através do menu de contexto em navegadores baseados em Chromium.
Acesse facilmente ferramentas de análise de web performance através do menu de contexto em navegadores baseados em Chromium.

## Ferramentas

- [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/)

## Instalação

Expand All @@ -18,7 +28,5 @@ Acesse PageSpeed, BuiltWith e Image Analysis Tool by Cloudinary através do menu

No site que deseja analisar, clique com o botão direito em qualquer área da página para acessar o menu; uma nova aba será aberta na ferramenta selecionada e a análise começará automaticamente.

## Notas

- O uso de VPNs não é permitido pela ferramenta **BuiltWith**.
- A análise feita pela ferramenta **Image Analysis Tool by Cloudinary** leva alguns milésimos para iniciar; após selecioná-la no menu, aguarde.
> [!NOTE]
> A análise feita pela ferramenta **Image Analysis Tool by Cloudinary** leva alguns segundos para iniciar; após selecioná-la no menu, aguarde.
Binary file modified assets/context-menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 98 additions & 3 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ chrome.runtime.onInstalled.addListener(() => {
const sites = [
{ 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" },
];

for (const site of sites) {
Expand All @@ -20,11 +24,15 @@ chrome.contextMenus.onClicked.addListener((info, tab) => {
tab.url
)}`,
BuiltWith: `https://builtwith.com/?${encodeURIComponent(tab.url)}`,
Cloudinary: `https://webspeedtest-api.cloudinary.com/test/run`,
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)}`,
};

if (info.menuItemId === "Cloudinary") {
async function sendPostRequest(url) {
async function sendPostRequestCloudinary(url) {
try {
const response = await fetch(siteUrls.Cloudinary, {
method: "POST",
Expand All @@ -47,7 +55,94 @@ chrome.contextMenus.onClicked.addListener((info, tab) => {
}
}

sendPostRequest(tab.url);
sendPostRequestCloudinary(tab.url);
} else if (info.menuItemId === "Yellow") {
async function sendPostRequestYellow(url) {
try {
const request = {
url: url,
waitForResponse: false,
screenshot: true,
device: "phone",
};

const response = await fetch(siteUrls.Yellow, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(request),
});

const data = await response.json();
const runId = data.runId;
const runUrl = `https://yellowlab.tools/queue/${runId}`;

chrome.tabs.create({ url: runUrl });
} catch (error) {
console.error("Erro ao enviar URL para Yellow Lab Tools:", error);
}
}

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
16 changes: 11 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
{
"manifest_version": 3,
"name": "Celeridade",
"version": "0.1.1",
"description": "Acesse ferramentas de análise de performance de sites através do menu de contexto.",
"homepage_url": "https://github.com/Celere-WP/celeridade",
"name": "Célere Toolkit",
"version": "0.2",
"description": "Acesse facilmente ferramentas de análise de web performance através do menu de contexto.",
"homepage_url": "https://github.com/Celere-WP/celere-toolkit",
"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 2059e2d

Please sign in to comment.