From cc32abf47bcfc7f00ed51a453cd90044f053f99a Mon Sep 17 00:00:00 2001 From: Author Name ikipatang <5412352+ikipatang@users.noreply.github.com> Date: Sun, 19 Nov 2017 02:05:28 +0100 Subject: [PATCH] Add share link and URL settings --- background.js | 24 ++++++++++++++++++++++++ options/options.css | 18 ++++++++++++++++++ options/options.html | 17 +++++++++++++++++ options/options.js | 38 ++++++++++++++++++++++++++++++++++++++ storage.js | 26 ++++++++++++++++++++++++++ 5 files changed, 123 insertions(+) create mode 100644 background.js create mode 100644 options/options.css create mode 100644 options/options.html create mode 100644 options/options.js create mode 100644 storage.js diff --git a/background.js b/background.js new file mode 100644 index 0000000..0977326 --- /dev/null +++ b/background.js @@ -0,0 +1,24 @@ +/** + * Share Current Tab + * @return {void} - + */ +function shareCurrentTab() { + browser.tabs.query({ + active: true, + currentWindow: true, + }).then((tabs) => { + const url = tabs[0].url; + const title = tabs[0].title || url; + browser.storage.local.get('url').then((storage) => { + const shareUrl = `${storage.url}?post=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&source=bookmarklet`; + + browser.windows.create({ + url: shareUrl, + type: 'popup', + allowScriptsToClose: true, + }); + }); + }); +} + +browser.browserAction.onClicked.addListener(shareCurrentTab); diff --git a/options/options.css b/options/options.css new file mode 100644 index 0000000..19f36be --- /dev/null +++ b/options/options.css @@ -0,0 +1,18 @@ + +body { + width: 25em; + font-family: "Open Sans Light", sans-serif; + font-size: 0.9em; + font-weight: 300; +} + +input#url { + margin: 0.5em; + width: 50em; + height: 2.5em; +} + +input { + width: 20em; + height: 2.5em; +} diff --git a/options/options.html b/options/options.html new file mode 100644 index 0000000..681b6de --- /dev/null +++ b/options/options.html @@ -0,0 +1,17 @@ + + + +
+ + + + + + +