diff --git a/README.md b/README.md index 8a16e8c..eb2f2e2 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. diff --git a/assets/context-menu.png b/assets/context-menu.png index 1de1208..6e3104c 100644 Binary files a/assets/context-menu.png and b/assets/context-menu.png differ diff --git a/background.js b/background.js index d2ddffa..c72d3b3 100644 --- a/background.js +++ b/background.js @@ -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) { @@ -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", @@ -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] }); } diff --git a/manifest.json b/manifest.json index 2f2401d..ce5254a 100644 --- a/manifest.json +++ b/manifest.json @@ -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"