Skip to content

Commit 2059e2d

Browse files
authored
Merge pull request #1 from Celere-WP/v0.2
v0.2
2 parents a585794 + a613375 commit 2059e2d

File tree

4 files changed

+123
-14
lines changed

4 files changed

+123
-14
lines changed

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
# Celeridade
1+
# Célere Toolkit
22

3-
Acesse PageSpeed, BuiltWith e Image Analysis Tool by Cloudinary através do menu de contexto em navegadores baseados em Chromium.
3+
Acesse facilmente ferramentas de análise de web performance através do menu de contexto em navegadores baseados em Chromium.
4+
5+
## Ferramentas
6+
7+
- [PageSpeed](https://pagespeed.web.dev/)
8+
- [BuiltWith](https://builtwith.com/)
9+
- [Yellow Lab Tools](https://yellowlab.tools/)
10+
- [InspectWP](https://inspectwp.com/en)
11+
- [Siteliner](https://www.siteliner.com/)
12+
- [Image Analysis Tool by Cloudinary](https://webspeedtest.cloudinary.com/)
13+
- [W3C Markup Validation Service](https://validator.w3.org/)
414

515
## Instalação
616

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

1929
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.
2030

21-
## Notas
22-
23-
- O uso de VPNs não é permitido pela ferramenta **BuiltWith**.
24-
- A análise feita pela ferramenta **Image Analysis Tool by Cloudinary** leva alguns milésimos para iniciar; após selecioná-la no menu, aguarde.
31+
> [!NOTE]
32+
> A análise feita pela ferramenta **Image Analysis Tool by Cloudinary** leva alguns segundos para iniciar; após selecioná-la no menu, aguarde.

assets/context-menu.png

-72 Bytes
Loading

background.js

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ chrome.runtime.onInstalled.addListener(() => {
22
const sites = [
33
{ id: "PageSpeed", title: "PageSpeed" },
44
{ id: "BuiltWith", title: "BuiltWith" },
5+
{ id: "Yellow", title: "Yellow Lab Tools" },
6+
{ id: "InspectWP", title: "InspectWP" },
7+
{ id: "Siteliner", title: "Siteliner" },
58
{ id: "Cloudinary", title: "Image Analysis Tool by Cloudinary" },
9+
{ id: "W3C", title: "W3C Markup Validation Service" },
610
];
711

812
for (const site of sites) {
@@ -20,11 +24,15 @@ chrome.contextMenus.onClicked.addListener((info, tab) => {
2024
tab.url
2125
)}`,
2226
BuiltWith: `https://builtwith.com/?${encodeURIComponent(tab.url)}`,
23-
Cloudinary: `https://webspeedtest-api.cloudinary.com/test/run`,
27+
Yellow: "https://yellowlab.tools/api/runs",
28+
InspectWP: "https://inspectwp.com/en",
29+
Siteliner: "https://www.siteliner.com/",
30+
Cloudinary: "https://webspeedtest-api.cloudinary.com/test/run",
31+
W3C: `https://validator.w3.org/nu/?doc=${encodeURIComponent(tab.url)}`,
2432
};
2533

2634
if (info.menuItemId === "Cloudinary") {
27-
async function sendPostRequest(url) {
35+
async function sendPostRequestCloudinary(url) {
2836
try {
2937
const response = await fetch(siteUrls.Cloudinary, {
3038
method: "POST",
@@ -47,7 +55,94 @@ chrome.contextMenus.onClicked.addListener((info, tab) => {
4755
}
4856
}
4957

50-
sendPostRequest(tab.url);
58+
sendPostRequestCloudinary(tab.url);
59+
} else if (info.menuItemId === "Yellow") {
60+
async function sendPostRequestYellow(url) {
61+
try {
62+
const request = {
63+
url: url,
64+
waitForResponse: false,
65+
screenshot: true,
66+
device: "phone",
67+
};
68+
69+
const response = await fetch(siteUrls.Yellow, {
70+
method: "POST",
71+
headers: {
72+
"Content-Type": "application/json",
73+
},
74+
body: JSON.stringify(request),
75+
});
76+
77+
const data = await response.json();
78+
const runId = data.runId;
79+
const runUrl = `https://yellowlab.tools/queue/${runId}`;
80+
81+
chrome.tabs.create({ url: runUrl });
82+
} catch (error) {
83+
console.error("Erro ao enviar URL para Yellow Lab Tools:", error);
84+
}
85+
}
86+
87+
sendPostRequestYellow(tab.url);
88+
} else if (info.menuItemId === "InspectWP") {
89+
try {
90+
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
91+
const activeTab = tabs[0];
92+
const activeTabUrl = activeTab.url;
93+
94+
chrome.tabs.create({ url: siteUrls.InspectWP }, (newTab) => {
95+
chrome.tabs.onUpdated.addListener(function onUpdated(
96+
tabId,
97+
changeInfo
98+
) {
99+
if (tabId === newTab.id && changeInfo.status === "complete") {
100+
chrome.scripting.executeScript({
101+
target: { tabId: newTab.id },
102+
func: (url) => {
103+
document.getElementById(
104+
"inspectwp-checker-form-url-input"
105+
).value = url;
106+
document.querySelector("div.input-group button").click();
107+
},
108+
args: [activeTabUrl],
109+
});
110+
chrome.tabs.onUpdated.removeListener(onUpdated);
111+
}
112+
});
113+
});
114+
});
115+
} catch (error) {
116+
console.error("Erro ao enviar URL para InspectWP:", error);
117+
}
118+
} else if (info.menuItemId === "Siteliner") {
119+
try {
120+
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
121+
const activeTab = tabs[0];
122+
const activeTabUrl = activeTab.url;
123+
124+
chrome.tabs.create({ url: siteUrls.Siteliner }, (newTab) => {
125+
chrome.tabs.onUpdated.addListener(function onUpdated(
126+
tabId,
127+
changeInfo
128+
) {
129+
if (tabId === newTab.id && changeInfo.status === "complete") {
130+
chrome.scripting.executeScript({
131+
target: { tabId: newTab.id },
132+
func: (url) => {
133+
document.getElementById("field-domain").value = url;
134+
document.getElementById("button-check-new").click();
135+
},
136+
args: [activeTabUrl],
137+
});
138+
chrome.tabs.onUpdated.removeListener(onUpdated);
139+
}
140+
});
141+
});
142+
});
143+
} catch (error) {
144+
console.error("Erro ao enviar URL para Siteliner:", error);
145+
}
51146
} else if (siteUrls[info.menuItemId]) {
52147
chrome.tabs.create({ url: siteUrls[info.menuItemId] });
53148
}

manifest.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
{
22
"manifest_version": 3,
3-
"name": "Celeridade",
4-
"version": "0.1.1",
5-
"description": "Acesse ferramentas de análise de performance de sites através do menu de contexto.",
6-
"homepage_url": "https://github.com/Celere-WP/celeridade",
3+
"name": "Célere Toolkit",
4+
"version": "0.2",
5+
"description": "Acesse facilmente ferramentas de análise de web performance através do menu de contexto.",
6+
"homepage_url": "https://github.com/Celere-WP/celere-toolkit",
77
"author": "Célere",
88
"permissions": [
99
"contextMenus",
10-
"tabs"
10+
"tabs",
11+
"activeTab",
12+
"scripting"
13+
],
14+
"host_permissions": [
15+
"https://www.siteliner.com/*",
16+
"https://inspectwp.com/en/*"
1117
],
1218
"background": {
1319
"service_worker": "background.js"

0 commit comments

Comments
 (0)