Skip to content

Commit

Permalink
Added ability to shorten link from context menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
pilar6195 committed Oct 24, 2019
1 parent bc7cedb commit 5a7353f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "long.af-extension",
"description": "Extension for long.af",
"version": "1.3",
"version": "1.4",
"author": "pilar6195",
"license": "MIT",
"devDependencies": {
Expand Down
18 changes: 13 additions & 5 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ function copyText(text) {
input.remove();
}

browser.notifications.onClicked.addListener(browser.notifications.clear);

/* On extension icon click */
browser.browserAction.onClicked.addListener(tab => {
function shortenLink(url) {
browser.storage.local.get({
expires: null,
type: null,
Expand All @@ -44,7 +41,7 @@ browser.browserAction.onClicked.addListener(tab => {
headers: { 'Content-Type': 'application/json' },
method: 'POST',
body: JSON.stringify({
url: tab.url,
url: url,
expires: items.expires,
type: items.type
})
Expand All @@ -67,4 +64,15 @@ browser.browserAction.onClicked.addListener(tab => {
browser.browserAction.setBadgeText({ text: '' });
}
});
}

/* On extension icon click */
browser.browserAction.onClicked.addListener(tab => shortenLink(tab.url));

browser.notifications.onClicked.addListener(browser.notifications.clear);

chrome.contextMenus.create({
title: 'long.af',
contexts: ['page', 'link'],
onclick: a => shortenLink(a.linkUrl || a.pageUrl)
});
3 changes: 2 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "long.af - URL Shortener",
"description": "Companion extension for https://long.af",
"version": "1.3",
"version": "1.4",
"minimum_chrome_version": "60.0.3112",
"options_ui": {
"page": "options.html",
Expand All @@ -11,6 +11,7 @@
"permissions": [
"https://api.long.af/*",
"activeTab",
"contextMenus",
"notifications",
"clipboardWrite",
"storage"
Expand Down

0 comments on commit 5a7353f

Please sign in to comment.