Skip to content

Commit

Permalink
Added quick actions for going to homepage, options page, and viewing …
Browse files Browse the repository at this point in the history
…passphrase links from extension popup.
  • Loading branch information
Aditya Dedhia committed May 23, 2023
1 parent b6687b1 commit 550c77e
Show file tree
Hide file tree
Showing 15 changed files with 369 additions and 81 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# downsize.link

## Deployment

1. Duplicate the entire project folder and remove the following contents:
- `README.md`
- `.gitignore`
- promo/

2. Zip the remaining contents
3. Rename the zip file to `downsize.link.zip`
4. Upload zip file and make any changes in description, screenshots, etc. on the store.

## Localised Descriptions

### EN

For people who want greater privacy and data ownership whilst browsing the web, downsize.link shortens your links and protect your privacy by blocking harmful sites and removing unnecessary URL parameters.

To begin, simply click the extension and choose the duration you would like to keep your link alive to shorten the active tab's URL. The link will continue to stay alive as long as it is opened during the selected interval. Your generated link ID will be between 1 to 5 characters long based on the interval you choose.

Whilst browsing, right click on any link you are unsure about on the webpage to open securely by routing the link through downsize.link. To quickly save the current page's shortened link, use the keyboard shortcut (CTRL/CMD + Shift + K), you may get prompted for permission to do.

If you have set a passphrase in the extension options, then your links will be accessible from the popup in a list view by clicking the 'view pass links` button on the extension.

Extension Preferences:
You can access preferences by right-clicking the extension and clicking options.

- By default, the extension presumes a QWERTY keyboard layout for generating easy to type URLs, you should change this if your keyboard layout is different.
- If you want to group links together for later access, you can set a passphrase in the extension options and change this as frequently as you wish. You can access the grouped links y entering the passphrase from the website.

### ES

Para aquellas personas que buscan una mayor privacidad y control sobre sus datos al navegar por Internet, downsize.link acorta los enlaces y protege la privacidad del usuario al bloquear sitios potencialmente dañinos y eliminar parámetros innecesarios de las URLs.

Para usar: se debe hacer clic en la extensión, seleccionar la duración que se desea mantener activo el enlace y, automáticamente, se acortará la URL de la pestaña en uso. El enlace permanecerá activo siempre y cuando se abra dentro del intervalo de tiempo seleccionado. Dependiendo del intervalo de tiempo elegido, la ID del enlace generado constará de entre 1 y 5 caracteres.

Mientras se navega, si se encuentra con algún enlace que genere dudas, se puede hacer clic derecho sobre él y seleccionar la opción de abrir el enlace a través de downsize.link. Para guardar rápidamente el enlace acortado de la página actual, se puede usar el atajo de teclado (CTRL/CMD + Shift + K), es posible que se solicite permiso para hacerlo.

Si usted ha establecido una frase de contraseña en las opciones de la extensión, entonces sus enlaces serán accesibles desde el popup en una vista de lista al hacer clic en el botón 'ver enlaces' en la extensión.

Preferencias de la extensión:
Para acceder a las preferencias, se debe hacer clic derecho sobre la extensión y seleccionar opciones.

- De forma predeterminada, la extensión asume un teclado QWERTY para generar URLs que sean fáciles de escribir. Si su teclado es diferente, se recomienda cambiar esta configuración.
- Si se desean agrupar varios enlaces para acceder a ellos posteriormente, se puede establecer una frase de contraseña en las opciones de la extensión y modificarla tantas veces como se desee. Para acceder a los enlaces agrupados, solo es necesario introducir la frase de contraseña desde la página web.
14 changes: 13 additions & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,17 @@
"savedToClipboardAlert": {
"message": "Link saved to clipboard!",
"description": "Saved to clipboard alert"
},
"passphraseTooShortAlert": {
"message": "Passphrase is too short!",
"description": "Passphrase too short alert"
},
"passphraseTooLongAlert": {
"message": "Passphrase is too long!",
"description": "Passphrase too long alert"
},
"accessPassphrase": {
"message": "view pass links",
"description": "Access passphrase"
}
}
}
14 changes: 13 additions & 1 deletion _locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,17 @@
"savedToClipboardAlert": {
"message": "¡Enlace copiado al portapapeles!",
"description": "Saved to clipboard alert"
},
"passphraseTooShortAlert": {
"message": "¡La contraseña es demasiado corta!",
"description": "Passphrase too short alert"
},
"passphraseTooLongAlert": {
"message": "¡La contraseña es demasiado larga!",
"description": "Passphrase too long alert"
},
"accessPassphrase": {
"message": "ver enlaces",
"description": "Access passphrase"
}
}
}
61 changes: 45 additions & 16 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
let contextMenuCreated = false;
if (!contextMenuCreated) {
chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({
id: "link-selector",
title: chrome.i18n.getMessage("contextMenuLinkSelectTitle"),
contexts: ["link"]
});
contextMenuCreated = true;
}
});

chrome.contextMenus.onClicked.addListener(function(info, tab) {
if (info.menuItemId === "link-selector") {
(async () => {
try {
let url = await fetchData(info.linkUrl, 1); // link/mode
console.log("Routed link: " + url);
let url = await fetchData(info.linkUrl, -1); // negative mode
if (!/^https?:\/\//i.test(url)) {
url = 'https://' + url;
}
Expand All @@ -26,16 +23,6 @@ chrome.contextMenus.onClicked.addListener(function(info, tab) {
});


async function copyToClipboard(text) {
try {
await navigator.clipboard.writeText(text);
return true;
} catch (err) {
console.error('Failed to copy text: ', err);
return false;
}
}

function getPassphrase() {
return new Promise((resolve, reject) => {
chrome.storage.local.get('passphrase', (data) => {
Expand Down Expand Up @@ -103,3 +90,45 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {

return true;
});

chrome.commands.onCommand.addListener(async (command) => {
if (command === 'copy_clipboard') {
// Get the active tab in the current window
chrome.tabs.query({ active: true, currentWindow: true }, async (tabs) => {
const response = await fetchData(tabs[0].url, 1); // tab/mode
// Inject a content script into the active tab and send the response to it
if (response) {
chrome.scripting.executeScript({
target: { tabId: tabs[0].id },
function: copyToClipboard,
args: [response]
});
}
});
}
});

function copyToClipboard(data) {
navigator.clipboard.writeText(data).then(() => {
console.log('Copied to clipboard: ' + data);
}, (err) => {
console.error('Failed to copy text: ', err);
});
}


chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.message === 'getPassphrase') {
getPassphrase()
.then(passphrase => {
sendResponse({ passphrase: passphrase });
})
.catch(error => {
sendResponse({ error: error });
});

// Indicate that response is async
return true;
}
});

61 changes: 38 additions & 23 deletions css/options.css
Original file line number Diff line number Diff line change
@@ -1,81 +1,96 @@
body {
margin: 10px;
padding: 10px;

user-select: none;

color: #333;
background-color: #f5f5f5;

font-family: "Comic Sans MS", cursive, sans-serif;
font-size: 16px;
line-height: 1.42857143;
color: #333;
margin: 10px;
padding: 10px;
user-select: none;
}

#optionsTitle {
color: #5046e5;
text-align: center;

color: #5046e5;
}

#options-form {
display: flex;
flex-direction: column;
align-items: center;
flex-direction: column;
justify-content: center;

margin: 5px;
padding: 5px;

border-radius: 10px;
}

#options-form div {
display: flex;
flex-direction: row;
align-items: center;
flex-direction: row;

margin: 5px;
padding: 5px;

border-radius: 10px;
}

input {
margin: 5px;
padding: 8px;

border: 1px solid #ccc;
border-radius: 5px;
padding: 8px;
margin: 5px;
}

select {
margin: 5px;
padding: 6px;

border: 1px solid #ccc;
border-radius: 5px;
padding: 6px;
margin: 5px;
}

#passphraseNote {
background-color: lightsalmon;
font-size: 14px;
border-radius: 5px;
padding: 5px;
margin: 5px;
padding: 5px;

border-radius: 5px;
background-color: lightsalmon;
box-shadow: 2px 2px 4px #ccc;

font-size: 14px;
}

#saveButton {
background-color: #5046e5;
margin: 5px;
padding: 8px;

cursor: pointer;

color: white;
border: none;
border-radius: 5px;
padding: 8px;
margin: 5px;
cursor: pointer;
background-color: #5046e5;
}
#saveButton:hover {
background-color: #3c34c7;
box-shadow: 0 0 2px #3c34c7;
}

#success-banner {
background-color: #d4edda;
margin: 5px;
padding: 8px;

color: #155724;
border: 1px solid #c3e6cb;
border-radius: 5px;
padding: 8px;
margin: 5px;
background-color: #d4edda;
box-shadow: 2px 2px 4px #ccc;
}
}
Loading

0 comments on commit 550c77e

Please sign in to comment.