Skip to content

Commit

Permalink
adiciona v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
claromes committed Sep 10, 2024
0 parents commit 33a2109
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Celeridade

Acesse PageSpeed, BuiltWith e Cloudinary Web Speed Test através do menu de contexto em navegadores baseados em Chromium.

## Instalação

- Faça o download do arquivo `celeridade-v0.1.zip`.
- 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.

## Notas

- O uso de VPNs não é permitido pela ferramenta **BuiltWith**.
- A análise feita pela ferramenta **Cloudinary Web Speed Test** leva alguns milésimos para iniciar; após selecioná-la no menu, aguarde.
Binary file added 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.
54 changes: 54 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
chrome.runtime.onInstalled.addListener(() => {
const sites = [
{ id: "PageSpeed", title: "PageSpeed" },
{ id: "BuiltWith", title: "BuiltWith" },
{ id: "Cloudinary", title: "Cloudinary Web Speed Test" },
];

for (const site of sites) {
chrome.contextMenus.create({
id: site.id,
title: site.title,
contexts: ["all"],
});
}
});

chrome.contextMenus.onClicked.addListener((info, tab) => {
const siteUrls = {
PageSpeed: `https://pagespeed.web.dev/analysis?url=${encodeURIComponent(
tab.url
)}`,
BuiltWith: `https://builtwith.com/?${encodeURIComponent(tab.url)}`,
Cloudinary: `https://webspeedtest-api.cloudinary.com/test/run`,
};

if (info.menuItemId === "Cloudinary") {
async function sendPostRequest(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}`;

chrome.tabs.create({ url: analysisUrl });
} catch (error) {
console.error(
"Erro ao enviar URL para Cloudinary Web Speed Test:",
error
);
}
}

sendPostRequest(tab.url);
} else if (siteUrls[info.menuItemId]) {
chrome.tabs.create({ url: siteUrls[info.menuItemId] });
}
});
Binary file added icons/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"manifest_version": 3,
"name": "Celeridade",
"version": "0.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",
"author": "Célere",
"permissions": [
"contextMenus",
"tabs"
],
"background": {
"service_worker": "background.js"
},
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
}
}

0 comments on commit 33a2109

Please sign in to comment.