Custom icon, change when active
@@ -2,6 +2,26 @@
|
|||||||
|
|
||||||
const reData = new RegExp('^data:(.*?);base64,(.*)$');
|
const reData = new RegExp('^data:(.*?);base64,(.*)$');
|
||||||
|
|
||||||
|
const idleIcon = {
|
||||||
|
path: {
|
||||||
|
16: 'icons/idle-16.png',
|
||||||
|
48: 'icons/idle-48.png',
|
||||||
|
64: 'icons/idle-64.png',
|
||||||
|
128: 'icons/idle-128.png',
|
||||||
|
256: 'icons/idle-256.png',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const activeIcon = {
|
||||||
|
path: {
|
||||||
|
16: 'icons/active-16.png',
|
||||||
|
48: 'icons/active-48.png',
|
||||||
|
64: 'icons/active-64.png',
|
||||||
|
128: 'icons/active-128.png',
|
||||||
|
256: 'icons/active-256.png',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
async function handleClick(tab, e) {
|
async function handleClick(tab, e) {
|
||||||
if (e.modifiers.includes('Shift')) {
|
if (e.modifiers.includes('Shift')) {
|
||||||
await sendPaste();
|
await sendPaste();
|
||||||
@@ -22,14 +42,12 @@ async function handleClick(tab, e) {
|
|||||||
|
|
||||||
noteParts.push('</body>');
|
noteParts.push('</body>');
|
||||||
|
|
||||||
const store = {};
|
await queue('create', {
|
||||||
store[`create_${crypto.randomUUID()}`] = {
|
|
||||||
name: tab.title,
|
name: tab.title,
|
||||||
html_notes: noteParts.join(''),
|
html_notes: noteParts.join(''),
|
||||||
attach: imgURL,
|
attach: imgURL,
|
||||||
filename: 'screenshot.png',
|
filename: 'screenshot.png',
|
||||||
};
|
});
|
||||||
await browser.storage.local.set(store);
|
|
||||||
|
|
||||||
if (!e.modifiers.includes('Command')) {
|
if (!e.modifiers.includes('Command')) {
|
||||||
browser.tabs.remove([tab.id]);
|
browser.tabs.remove([tab.id]);
|
||||||
@@ -39,12 +57,10 @@ async function handleClick(tab, e) {
|
|||||||
async function sendPaste() {
|
async function sendPaste() {
|
||||||
const clip = await navigator.clipboard.readText();
|
const clip = await navigator.clipboard.readText();
|
||||||
|
|
||||||
const store = {};
|
await queue('create', {
|
||||||
store[`create_${crypto.randomUUID()}`] = {
|
|
||||||
name: 'Paste',
|
name: 'Paste',
|
||||||
html_notes: `<body>${escapeHTML(clip)}</body>`,
|
html_notes: `<body>${escapeHTML(clip)}</body>`,
|
||||||
};
|
});
|
||||||
await browser.storage.local.set(store);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let inHandleChange = false;
|
let inHandleChange = false;
|
||||||
@@ -68,6 +84,7 @@ async function handleChangeInt(e) {
|
|||||||
const keys = Object.getOwnPropertyNames(queue);
|
const keys = Object.getOwnPropertyNames(queue);
|
||||||
|
|
||||||
if (keys.length == 0) {
|
if (keys.length == 0) {
|
||||||
|
browser.browserAction.setIcon(idleIcon);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,13 +132,11 @@ async function create(cfg, task) {
|
|||||||
const create = await createResp.json();
|
const create = await createResp.json();
|
||||||
|
|
||||||
if (task.attach) {
|
if (task.attach) {
|
||||||
const store = {};
|
await queue('attach', {
|
||||||
store[`attach_${crypto.randomUUID()}`] = {
|
|
||||||
gid: create.data.gid,
|
gid: create.data.gid,
|
||||||
attach: task.attach,
|
attach: task.attach,
|
||||||
filename: task.filename,
|
filename: task.filename,
|
||||||
};
|
});
|
||||||
await browser.storage.local.set(store);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +162,14 @@ async function attach(cfg, task) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function queue(type, details) {
|
||||||
|
browser.browserAction.setIcon(activeIcon);
|
||||||
|
|
||||||
|
const store = {};
|
||||||
|
store[`${type}_${crypto.randomUUID()}`] = details;
|
||||||
|
await browser.storage.local.set(store);
|
||||||
|
}
|
||||||
|
|
||||||
async function getSelectedText(tabId) {
|
async function getSelectedText(tabId) {
|
||||||
const selecteds = await browser.tabs.executeScript(
|
const selecteds = await browser.tabs.executeScript(
|
||||||
tabId,
|
tabId,
|
||||||
|
|||||||
BIN
icons/active-128.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
icons/active-16.png
Normal file
|
After Width: | Height: | Size: 482 B |
BIN
icons/active-256.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
icons/active-48.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
icons/active-64.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
icons/asana.png
|
Before Width: | Height: | Size: 423 B |
BIN
icons/idle-128.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
icons/idle-16.png
Normal file
|
After Width: | Height: | Size: 333 B |
BIN
icons/idle-256.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
icons/idle-48.png
Normal file
|
After Width: | Height: | Size: 744 B |
BIN
icons/idle-64.png
Normal file
|
After Width: | Height: | Size: 886 B |
@@ -1,30 +1,40 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Quick Asana",
|
"name": "Quick Asana",
|
||||||
"version": "0.1",
|
"version": "0.1",
|
||||||
"icons": {
|
"icons": {
|
||||||
"48": "icons/asana.png"
|
"16": "icons/idle-16.png",
|
||||||
},
|
"48": "icons/idle-48.png",
|
||||||
|
"64": "icons/idle-64.png",
|
||||||
|
"128": "icons/idle-128.png",
|
||||||
|
"256": "icons/idle-256.png"
|
||||||
|
},
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"clipboardRead",
|
"clipboardRead",
|
||||||
"storage",
|
"storage",
|
||||||
"unlimitedStorage",
|
"unlimitedStorage",
|
||||||
"<all_urls>"
|
"<all_urls>"
|
||||||
],
|
],
|
||||||
|
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"default_icon": "icons/asana.png",
|
"default_icon": {
|
||||||
"default_title": "Quick Asana"
|
"16": "icons/idle-16.png",
|
||||||
},
|
"48": "icons/idle-48.png",
|
||||||
|
"64": "icons/idle-64.png",
|
||||||
|
"128": "icons/idle-128.png",
|
||||||
|
"256": "icons/idle-256.png"
|
||||||
|
},
|
||||||
|
"default_title": "Quick Asana"
|
||||||
|
},
|
||||||
|
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["background.js"]
|
"scripts": ["background.js"]
|
||||||
},
|
},
|
||||||
|
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "{073d8528-4b24-11ed-9b73-c71d3da4ab37}"
|
"id": "{073d8528-4b24-11ed-9b73-c71d3da4ab37}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||