diff --git a/LICENSE b/LICENSE index 0f5158d..8dc1861 100644 --- a/LICENSE +++ b/LICENSE @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - Access website performance analysis tools via context menu. - Copyright (C) 2024 Célere + Easily access web performance analysis tools through the context menu. + Copyright (C) 2024 Célere/Clarissa Mendes This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Celeridade: Browser Extension Copyright (C) 2024 Célere + Célere Toolkit Copyright (C) 2024 Célere/Clarissa Mendes This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/README.md b/README.md index eb2f2e2..6751b87 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ +English (US) | [Português (BR)](./README.pt-BR.md) + # Célere Toolkit -Acesse facilmente ferramentas de análise de web performance através do menu de contexto em navegadores baseados em Chromium. +Easily access web performance analysis tools through the context menu in Chromium-based browsers. -## Ferramentas +## Tools - [PageSpeed](https://pagespeed.web.dev/) - [BuiltWith](https://builtwith.com/) @@ -12,21 +14,27 @@ Acesse facilmente ferramentas de análise de web performance através do menu de - [Image Analysis Tool by Cloudinary](https://webspeedtest.cloudinary.com/) - [W3C Markup Validation Service](https://validator.w3.org/) -## Instalação +## Installation -- [Faça o download do arquivo](https://github.com/Celere-WP/celeridade/releases). -- Extraia o arquivo ZIP. -- Abra o navegador baseado em Chromium e vá para `chrome://extensions`. -- Ative o "Modo Desenvolvedor" (localizado no canto superior direito). -- Clique no botão "Carregar sem compactação" (localizado no canto superior esquerdo). -- Navegue até o diretório onde você extraiu o arquivo ZIP contendo a extensão. -- Selecione a pasta da extensão. +- [Download the file](https://github.com/Celere-WP/celeridade/releases). +- Extract the ZIP file. +- Open the Chromium-based browser and go to `chrome://extensions`. +- Enable "Developer Mode" (located in the upper right corner). +- Click the "Load unpacked" button (located in the upper left corner). +- Navigate to the directory where you extracted the ZIP file containing the extension. +- Select the extension folder. -## Uso +## Usage -![Printscreen](assets/context-menu.png) +![Screenshot](assets/context-menu.png) -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. +On the site you want to analyze, right-click anywhere on the page to access the menu; a new tab will open in the selected tool and the analysis will start automatically. > [!NOTE] -> A análise feita pela ferramenta **Image Analysis Tool by Cloudinary** leva alguns segundos para iniciar; após selecioná-la no menu, aguarde. +> The analysis performed by the **Image Analysis Tool by Cloudinary** takes a few seconds to start; after selecting it from the menu, please wait. +> +> Each tool has its own access policies: request limits, IP or VPN blocking, and login requirements for some features. To avoid access issues, use the tools moderately and refer to the policies directly on the sites when necessary. + +## Contributing + +Feel free to submit issues or pull requests for any bug fixes or new features. They can be opened in English or Portuguese. diff --git a/README.pt-BR.md b/README.pt-BR.md new file mode 100644 index 0000000..bffe3de --- /dev/null +++ b/README.pt-BR.md @@ -0,0 +1,40 @@ +[English (US)](./README.md) | Português (BR) + +# Célere Toolkit + +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 + +- [Faça o download do arquivo](https://github.com/Celere-WP/celeridade/releases). +- Extraia o arquivo ZIP. +- Abra o navegador baseado em Chromium e vá para `chrome://extensions`. +- Ative o "Modo Desenvolvedor" (localizado no canto superior direito). +- Clique no botão "Carregar sem compactação" (localizado no canto superior esquerdo). +- Navegue até o diretório onde você extraiu o arquivo ZIP contendo a extensão. +- Selecione a pasta da extensão. + +## Uso + +![Printscreen](assets/context-menu.png) + +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. + +> [!NOTE] +> A análise feita pela ferramenta **Image Analysis Tool by Cloudinary** leva alguns segundos para iniciar; após selecioná-la no menu, aguarde. +> +> Cada ferramenta possui suas próprias políticas de acesso: limite de requisições, bloqueio de IPs ou VPNs, e requisitos de login em algumas funcionalidades. Para evitar problemas de acesso, utilize as ferramentas de forma moderada e consulte as políticas diretamente nos sites quando necessário. + +## Contribuições + +Sinta-se à vontade para enviar issues ou pull requests para qualquer correção de bugs ou novas funcionalidades. Eles podem ser abertos em inglês ou em português. diff --git a/assets/context-menu.png b/assets/context-menu.png index 6e3104c..16100d2 100644 Binary files a/assets/context-menu.png and b/assets/context-menu.png differ diff --git a/background.js b/background.js index c72d3b3..3e2be53 100644 --- a/background.js +++ b/background.js @@ -7,9 +7,18 @@ chrome.runtime.onInstalled.addListener(() => { { id: "Siteliner", title: "Siteliner" }, { id: "Cloudinary", title: "Image Analysis Tool by Cloudinary" }, { id: "W3C", title: "W3C Markup Validation Service" }, + { id: "All", title: "Open all tools" }, ]; for (const site of sites) { + if (site.id === "All") { + chrome.contextMenus.create({ + id: "separator-before-all", + type: "separator", + contexts: ["all"], + }); + } + chrome.contextMenus.create({ id: site.id, title: site.title, @@ -31,61 +40,84 @@ chrome.contextMenus.onClicked.addListener((info, tab) => { W3C: `https://validator.w3.org/nu/?doc=${encodeURIComponent(tab.url)}`, }; - if (info.menuItemId === "Cloudinary") { - async function sendPostRequestCloudinary(url) { - try { - const response = await fetch(siteUrls.Cloudinary, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ url }), - }); - - const data = await response.json(); - const analysisId = data.data.testId; - const analysisUrl = `https://webspeedtest.cloudinary.com/results/${analysisId}`; + if (info.menuItemId === "All") { + sendPostRequestCloudinary(tab.url); + sendPostRequestYellow(tab.url); + openInspectWP(); + openSiteliner(); - chrome.tabs.create({ url: analysisUrl }); - } catch (error) { - console.error( - "Erro ao enviar URL para Image Analysis Tool by Cloudinary:", - error - ); + { + for (const [id, url] of Object.entries(siteUrls)) { + if ( + id !== "Cloudinary" && + id !== "Yellow" && + id !== "InspectWP" && + id !== "Siteliner" + ) { + chrome.tabs.create({ url }); + } } } - + } else if (info.menuItemId === "Cloudinary") { 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), - }); + sendPostRequestYellow(tab.url); + } else if (info.menuItemId === "InspectWP") { + openInspectWP(); + } else if (info.menuItemId === "Siteliner") { + openSiteliner(); + } else if (siteUrls[info.menuItemId]) { + chrome.tabs.create({ url: siteUrls[info.menuItemId] }); + } + + async function sendPostRequestCloudinary(url) { + try { + const response = await fetch(siteUrls.Cloudinary, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ url }), + }); - const data = await response.json(); - const runId = data.runId; - const runUrl = `https://yellowlab.tools/queue/${runId}`; + const data = await response.json(); + const analysisId = data.data.testId; + const analysisUrl = `https://webspeedtest.cloudinary.com/results/${analysisId}`; - chrome.tabs.create({ url: runUrl }); - } catch (error) { - console.error("Erro ao enviar URL para Yellow Lab Tools:", error); - } + chrome.tabs.create({ url: analysisUrl }); + } catch (error) { + logging("Image Analysis Tool by Cloudinary", error); } + } - sendPostRequestYellow(tab.url); - } else if (info.menuItemId === "InspectWP") { + 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) { + logging("Yellow Lab Tools", error); + } + } + + function openInspectWP() { try { chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { const activeTab = tabs[0]; @@ -113,9 +145,11 @@ chrome.contextMenus.onClicked.addListener((info, tab) => { }); }); } catch (error) { - console.error("Erro ao enviar URL para InspectWP:", error); + logging("InspectWP", error); } - } else if (info.menuItemId === "Siteliner") { + } + + function openSiteliner() { try { chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { const activeTab = tabs[0]; @@ -141,9 +175,20 @@ chrome.contextMenus.onClicked.addListener((info, tab) => { }); }); } catch (error) { - console.error("Erro ao enviar URL para Siteliner:", error); + logging("Siteliner", error); } - } else if (siteUrls[info.menuItemId]) { - chrome.tabs.create({ url: siteUrls[info.menuItemId] }); + } + + function logging(toolName, error) { + chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { + const activeTab = tabs[0]; + chrome.scripting.executeScript({ + target: { tabId: activeTab.id }, + func: (errorMessage) => { + alert(errorMessage); + }, + args: [`Error sending URL to ${toolName}: ` + error], + }); + }); } }); diff --git a/icons/icon128.png b/icons/icon128.png index 6b23e93..54a3ea1 100644 Binary files a/icons/icon128.png and b/icons/icon128.png differ diff --git a/icons/icon16.png b/icons/icon16.png index f7d920f..5b701c2 100644 Binary files a/icons/icon16.png and b/icons/icon16.png differ diff --git a/icons/icon48.png b/icons/icon48.png index a9822d3..3a1719c 100644 Binary files a/icons/icon48.png and b/icons/icon48.png differ diff --git a/manifest.json b/manifest.json index ce5254a..b031d98 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "manifest_version": 3, "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", + "version": "0.3", + "description": "Easily access web performance analysis tools through the context menu.", + "homepage_url": "https://github.com/celere-dev/celere-toolkit", + "author": "Célere/Claromes", "permissions": [ "contextMenus", "tabs",