generalize to other domains, changed icons
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
examples
|
||||
web-ext-artifacts
|
||||
node_modules
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "Web Extension for Shaarli modified",
|
||||
"description": "Share your link to your Shaarli, test version",
|
||||
"version": "2.0.2",
|
||||
"version": "2.0.3",
|
||||
"homepage_url": "https://git.hmthsn.com/mantao/shaarli-web-extension",
|
||||
"manifest_version": 2,
|
||||
"icons": {
|
||||
"48": "resources/icons/icon-48.png"
|
||||
"48": "resources/icons/leaf_on.svg"
|
||||
},
|
||||
"permissions": [
|
||||
"tabs",
|
||||
@ -19,22 +19,18 @@
|
||||
"page": "src/background-page.html"
|
||||
},
|
||||
"browser_action": {
|
||||
"default_icon": "resources/icons/icon-24.png",
|
||||
"default_icon": "resources/icons/leaf_on.svg",
|
||||
"default_title": "Share"
|
||||
},
|
||||
"page_action": {
|
||||
"browser_style": false,
|
||||
"default_icon": "resources/icons/icon-24.png",
|
||||
"default_icon": "resources/icons/leaf_on.svg",
|
||||
"default_title": "Share"
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["*://sl.hmthsn.com/login*"],
|
||||
"js": ["src/login_helper.js"]
|
||||
},
|
||||
{
|
||||
"matches": ["*://sl.hmthsn.com/*"],
|
||||
"js": ["src/close_helper.js"]
|
||||
"matches": ["<all_urls>"],
|
||||
"js": ["src/login_close_helper.js"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 701 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 645 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 883 B |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
74
resources/icons/leaf_off.svg
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
id="Capa_1"
|
||||
enable-background="new 0 0 511.993 511.993"
|
||||
height="512"
|
||||
viewBox="0 0 511.993 511.993"
|
||||
width="512"
|
||||
version="1.1"
|
||||
sodipodi:docname="leaf_off.svg"
|
||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
|
||||
<metadata
|
||||
id="metadata11">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs9" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1563"
|
||||
inkscape:window-height="980"
|
||||
id="namedview7"
|
||||
showgrid="false"
|
||||
inkscape:zoom="1.3964844"
|
||||
inkscape:cx="256"
|
||||
inkscape:cy="256"
|
||||
inkscape:window-x="934"
|
||||
inkscape:window-y="384"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="g4" />
|
||||
<g
|
||||
id="g4">
|
||||
<path
|
||||
d="m 468.96915,162.0373 -10.701,-53.485 -29.796,11.928 c -26.143,10.465 -54.025,20.268 -83.065,29.209 -12.826,-34.907 -32.205,-69.601003 -57.737,-103.333003 l -32.918,-43.4920005 -21.632,23.7100005 c -34.48,37.794 -73.39,74.532003 -118.953,112.313003 -35.960002,29.818 -61.419002,71.481 -71.688002,117.315 -10.586,47.252 -5.016,95.319 16.109,139.002 l 57.864002,119.652 h 63.29 c 55.325,0 104.264,-8.484 145.455,-25.218 39.054,-15.866 71.373,-39.179 96.06,-69.292 51.519,-62.847 68.463,-154.583 47.712,-258.309 z m -51.072,-5.322 c -19.736,39.773 -44.423,79.234 -73.709,117.704 -30.104,39.543 -65.078,78.129 -103.951,114.687 -40.547,38.133 -77.008,66.134 -99.377,82.236 v -94.987 c 0,-41.682 13.663,-80.93 39.513,-113.501 25.092,-31.617 60.357,-54.319 99.299,-63.925 15.797,-3.897 31.323,-8.001 46.339,-12.243 l 0.026,0.081 13.714,-4.043 c 0.13,-0.038 0.261,-0.076 0.391,-0.114 v -0.001 c 26.915,-7.938 52.962,-16.625 77.755,-25.894 z M 71.753148,262.7613 c 8.824,-39.388 30.688002,-75.179 61.563002,-100.78 45.469,-37.703 84.526,-74.458003 119.281,-112.255003 l 11.153,14.735 c 23.284,30.763 40.994,62.223003 52.8,93.722003 -14.288,4.021 -29.047,7.915 -44.064,11.619 -45.354,11.188 -86.413,37.612 -115.612,74.403 -30.103,37.931 -46.014,83.627 -46.014,132.151 v 58.031 l -25.265002,-52.243 c -18.147,-37.524 -22.933,-78.806 -13.842,-119.383 z m 326.302002,138.567 c -21.476,26.197 -49.787,46.558 -84.149,60.517 -37.589,15.27 -82.728,23.012 -134.164,23.012 h -6.549 c 22.67,-17.036 53.314,-41.699 87.069,-73.4 40.169,-37.725 76.346,-77.598 107.526,-118.512 28.848,-37.854 53.449,-76.695 73.483,-115.928 16.254,90.951 1.03,170.337 -43.216,224.311 z"
|
||||
id="path2"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none;stroke-opacity:1" />
|
||||
<path
|
||||
style="fill:#969696;fill-opacity:0.25;stroke-width:13.5323"
|
||||
d="M 98.526127,408.11424 C 92.063189,394.75295 85.251734,380.43748 83.389561,376.3021 67.654847,341.35954 63.66835,301.96838 71.984028,263.60236 c 4.63759,-21.39644 14.193939,-43.69133 26.892849,-62.74082 10.840663,-16.26196 20.600873,-26.61515 43.024303,-45.63825 36.37673,-30.86049 60.11267,-52.85085 90.4321,-83.781583 l 20.51941,-20.933117 9.71606,13.056194 c 18.08531,24.30258 29.3399,42.319046 40.36346,64.614236 8.47993,17.15068 13.43071,29.18386 12.27094,29.82531 -0.79631,0.44043 -9.58602,2.81551 -42.01714,11.35352 -7.68,2.02188 -18.31384,5.29288 -23.63077,7.26888 -68.19227,25.34328 -118.89673,83.76587 -134.22332,154.65451 -3.84201,17.77008 -4.20683,22.73612 -4.64494,63.22741 l -0.41006,37.89885 z"
|
||||
id="path859"
|
||||
transform="scale(0.99998633)" />
|
||||
<path
|
||||
style="fill:#969696;fill-opacity:0.25;stroke-width:13.5323"
|
||||
d="m 141.62565,412.7514 0.27747,-57.57378 1.866,-10.02517 c 5.54306,-29.78034 16.49378,-54.83787 34.30986,-78.50806 12.1553,-16.14936 27.28929,-30.41618 44.26508,-41.72871 20.40595,-13.59837 36.07426,-20.23358 65.25402,-27.63373 41.50462,-10.52581 81.89324,-22.72454 116.55075,-35.20229 6.45416,-2.32369 11.88846,-4.07128 12.0762,-3.88353 0.18775,0.18775 -2.31244,5.4335 -5.55597,11.65723 -45.25414,86.83407 -117.43837,174.63117 -206.2271,250.83234 -17.87664,15.34228 -52.54437,42.77212 -61.08535,48.33204 l -2.00843,1.30743 z"
|
||||
id="path861"
|
||||
transform="scale(0.99998633)" />
|
||||
<path
|
||||
style="fill:#969696;fill-opacity:0.25;stroke-width:13.5323"
|
||||
d="m 175.82418,483.48192 c 0.5767,-0.52188 6.36547,-5.10048 12.86393,-10.17466 35.1357,-27.43498 67.87836,-56.71765 100.96874,-90.29911 61.3109,-62.22083 108.75826,-125.38797 145.53669,-193.75446 l 6.05194,-11.2498 1.53269,10.53372 c 4.23298,29.09211 5.46863,55.70946 3.69692,79.63582 -9.20281,124.28091 -85.50998,199.31565 -217.32824,213.70424 -14.33223,1.56442 -31.23287,2.5531 -43.64332,2.5531 -8.95661,0 -10.55478,-0.15667 -9.67935,-0.94885 z"
|
||||
id="path863"
|
||||
transform="scale(0.99998633)" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.3 KiB |
75
resources/icons/leaf_on.svg
Normal file
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
id="Capa_1"
|
||||
enable-background="new 0 0 512 512"
|
||||
height="512"
|
||||
viewBox="0 0 512 512"
|
||||
width="512"
|
||||
version="1.1"
|
||||
sodipodi:docname="leaf_on.svg"
|
||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
|
||||
<metadata
|
||||
id="metadata15">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs13" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="2075"
|
||||
inkscape:window-height="1497"
|
||||
id="namedview11"
|
||||
showgrid="false"
|
||||
inkscape:zoom="1.3964844"
|
||||
inkscape:cx="256"
|
||||
inkscape:cy="256"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="Capa_1" />
|
||||
<g
|
||||
id="g8"
|
||||
transform="matrix(0.93896889,0,0,0.94951462,15.623984,12.924257)">
|
||||
<path
|
||||
d="M 113.707,512 55.575,391.792 C 11.881,301.441 37.477,195.524 111.417,134.213 157.444,96.047 201.357,55.401 241.656,11.229 L 251.9,0 275.721,31.473 c 29.393,38.834 51.822,80.128 65.073,121.97 z"
|
||||
fill="#00aa95"
|
||||
id="path2" />
|
||||
<path
|
||||
d="m 468.766,149.938 -7.743,-38.704 C 422.754,201.441 324.597,249.373 268.334,311.617 169.942,420.469 113.707,512 113.707,512 h 58.256 c 258.928,0 334.274,-174.759 296.803,-362.062 z"
|
||||
fill="#00cc76"
|
||||
id="path4" />
|
||||
<path
|
||||
d="m 461.022,111.234 -14.112,5.649 c -34.771,13.919 -70.217,25.975 -106.117,36.56 v 10e-4 c -21.412,6.314 -42.985,12.104 -64.674,17.454 -93.258,23.005 -162.413,107.214 -162.413,207.575 V 512 c 10e-4,0 242.122,-152.806 347.316,-400.766 z"
|
||||
fill="#a5e887"
|
||||
id="path6" />
|
||||
</g>
|
||||
<g
|
||||
id="g4"
|
||||
transform="matrix(1.0000137,0,0,1.0000137,-1.4234701,0)">
|
||||
<path
|
||||
d="m 467.537,159.173 -10.701,-53.485 -29.796,11.928 c -26.143,10.465 -54.025,20.268 -83.065,29.209 C 331.149,111.918 311.77,77.224 286.238,43.492 L 253.32,0 231.688,23.71 c -34.48,37.794 -73.39,74.532 -118.953,112.313 -35.96,29.818 -61.419,71.481 -71.688,117.315 -10.586,47.252 -5.016,95.319 16.109,139.002 l 57.864,119.652 h 63.29 c 55.325,0 104.264,-8.484 145.455,-25.218 39.054,-15.866 71.373,-39.179 96.06,-69.292 51.519,-62.847 68.463,-154.583 47.712,-258.309 z m -51.072,-5.322 c -19.736,39.773 -44.423,79.234 -73.709,117.704 -30.104,39.543 -65.078,78.129 -103.951,114.687 -40.547,38.133 -77.008,66.134 -99.377,82.236 v -94.987 c 0,-41.682 13.663,-80.93 39.513,-113.501 25.092,-31.617 60.357,-54.319 99.299,-63.925 15.797,-3.897 31.323,-8.001 46.339,-12.243 l 0.026,0.081 13.714,-4.043 c 0.13,-0.038 0.261,-0.076 0.391,-0.114 v -0.001 c 26.915,-7.938 52.962,-16.625 77.755,-25.894 z M 70.321,259.897 c 8.824,-39.388 30.688,-75.179 61.563,-100.78 45.469,-37.703 84.526,-74.458 119.281,-112.255 l 11.153,14.735 c 23.284,30.763 40.994,62.223 52.8,93.722 -14.288,4.021 -29.047,7.915 -44.064,11.619 -45.354,11.188 -86.413,37.612 -115.612,74.403 -30.103,37.931 -46.014,83.627 -46.014,132.151 v 58.031 L 84.163,379.28 C 66.016,341.756 61.23,300.474 70.321,259.897 Z m 326.302,138.567 c -21.476,26.197 -49.787,46.558 -84.149,60.517 -37.589,15.27 -82.728,23.012 -134.164,23.012 h -6.549 c 22.67,-17.036 53.314,-41.699 87.069,-73.4 40.169,-37.725 76.346,-77.598 107.526,-118.512 28.848,-37.854 53.449,-76.695 73.483,-115.928 16.254,90.951 1.03,170.337 -43.216,224.311 z"
|
||||
id="path2-6" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
@ -1,13 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
"scripts": ["src/storage.js", "src/background.js"]
|
||||
<script src="lib/jquery-3.5.1.js"></script>
|
||||
<script src="lib/crypto-js.js"></script>
|
||||
<script src="lib/client.js"></script>
|
||||
<script type="module" src="storage.js"></script>
|
||||
<script type="module" src="background.js"></script>
|
||||
</head>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script src="lib/jquery-3.5.1.js"></script>
|
||||
<script src="lib/crypto-js.js"></script>
|
||||
<script src="lib/client.js"></script>
|
||||
<script type="module" src="storage.js"></script>
|
||||
<script type="module" src="background.js"></script>
|
||||
</head>
|
||||
|
||||
</html>
|
||||
@ -1,7 +1,3 @@
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Open the given url in a popup
|
||||
* @param {string} url -
|
||||
@ -9,6 +5,7 @@
|
||||
* @param {number} height -
|
||||
* @return {void} -
|
||||
*/
|
||||
|
||||
function openInPopup(url, width, height) {
|
||||
browser.windows.create({
|
||||
url,
|
||||
@ -26,7 +23,7 @@ var last_tab;
|
||||
function shareCurrentTab(tab) {
|
||||
const url = tab.url;
|
||||
const title = tab.title || url;
|
||||
browser.storage.local.get().then((storage) => {
|
||||
browser.storage.local.get("url").then((storage) => {
|
||||
if(!storage.url){
|
||||
browser.runtime.openOptionsPage();
|
||||
return;
|
||||
@ -42,7 +39,7 @@ function shareCurrentTab(tab) {
|
||||
* @return {void} -
|
||||
*/
|
||||
function showPageAction(tabId){
|
||||
browser.storage.local.get().then((storage) => {
|
||||
browser.storage.local.get("pageAction").then((storage) => {
|
||||
storage.pageAction ? browser.pageAction.show(tabId) : browser.pageAction.hide(tabId);
|
||||
});
|
||||
}
|
||||
@ -97,9 +94,9 @@ async function updateIcon() {
|
||||
// Set initial icon
|
||||
var runtimeUrl = await browser.runtime.getURL("/"),
|
||||
icon = {path: {
|
||||
16: "../resources/icons/action-default-16.png",
|
||||
32: "../resources/icons/action-default-32.png",
|
||||
64: "../resources/icons/action-default-64.png"
|
||||
16: "../resources/icons/leaf_off.svg",
|
||||
32: "../resources/icons/leaf_off.svg",
|
||||
64: "../resources/icons/leaf_off.svg"
|
||||
}};
|
||||
|
||||
// Firefox allows using empty object as default icon.
|
||||
@ -113,9 +110,9 @@ async function updateIcon() {
|
||||
var local = await findLocalBookmark(tab.url);
|
||||
|
||||
if (local) icon.path = {
|
||||
16: "../resources/icons/action-bookmarked-16.png",
|
||||
32: "../resources/icons/action-bookmarked-32.png",
|
||||
64: "../resources/icons/action-bookmarked-64.png"
|
||||
16: "../resources/icons/leaf_on.svg",
|
||||
32: "../resources/icons/leaf_on.svg",
|
||||
64: "../resources/icons/leaf_on.svg"
|
||||
}
|
||||
|
||||
// console.log("tab:", tab);
|
||||
@ -152,29 +149,38 @@ browser.contextMenus.create({
|
||||
}, onCreated);
|
||||
|
||||
async function sync_links(){
|
||||
var token = await browser.storage.local.get("token")
|
||||
token = token.token
|
||||
var result = await getLinks(token);
|
||||
// get server url from storage
|
||||
var storage_server_url = await browser.storage.local.get("url")
|
||||
if(!storage_server_url.url){
|
||||
return
|
||||
}
|
||||
let server_url = storage_server_url.url;
|
||||
// get token from storage
|
||||
var storage_token = await browser.storage.local.get("token")
|
||||
if(!storage_token.token){
|
||||
return
|
||||
}
|
||||
let token = storage_token.token;
|
||||
// construct api url
|
||||
let api_url = new URL(server_url);
|
||||
api_url.pathname = "/api/v1/links";
|
||||
api_url.searchParams.append("limit", "all");
|
||||
// get links
|
||||
var result = await getLinks(token, api_url.href);
|
||||
// generate link dictionary
|
||||
let links = {}
|
||||
result.forEach((value)=>{
|
||||
links[value.url] = true;
|
||||
})
|
||||
// save link dictionary
|
||||
browser.storage.local.set({"links":links});
|
||||
console.log(links);
|
||||
}
|
||||
browser.contextMenus.onClicked.addListener(async function(info, tab) {
|
||||
switch (info.menuItemId) {
|
||||
case "log-selection":
|
||||
await sync_links();
|
||||
break;
|
||||
|
||||
}
|
||||
})
|
||||
console.log("addon loaded")
|
||||
|
||||
|
||||
browser.runtime.onMessage.addListener(async (message) => {
|
||||
|
||||
console.log("sync signal received",message)
|
||||
if (message === "sync") {
|
||||
await new Promise(r => setTimeout(r, 1000));
|
||||
await sync_links();
|
||||
@ -183,5 +189,9 @@ browser.runtime.onMessage.addListener(async (message) => {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
console.log("addon loaded");
|
||||
sync_links();
|
||||
browser.storage.local.set({"attempt":0});
|
||||
browser.storage.local.set({"attempt":0});
|
||||
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
window.onbeforeunload = function() {
|
||||
browser.runtime.sendMessage("sync");
|
||||
}
|
||||
@ -9,21 +9,16 @@ function generateToken(secret){
|
||||
payload = base64url(`{
|
||||
"iat": ${Math.floor(Date.now() / 1000)}
|
||||
}`)
|
||||
console.log(payload)
|
||||
// payload = base64url(`{
|
||||
// "iat": 1605996074
|
||||
// }`)
|
||||
var hash = CryptoJS.HmacSHA512(header + '.'+ payload, secret);
|
||||
var signature = hash.toString(CryptoJS.enc.Base64).replace(/\=+$/m,'').replaceAll('/','_').replaceAll('+','-');
|
||||
return header + "." + payload + "." + signature
|
||||
}
|
||||
|
||||
async function getLinks(api_token){
|
||||
async function getLinks(api_token, url){
|
||||
let token = generateToken(api_token)
|
||||
var result = await $.ajax(
|
||||
{
|
||||
url: "https://sl.hmthsn.com/api/v1/links?limit=all",
|
||||
//url: "http://127.0.0.1:8081/",
|
||||
url: url,
|
||||
type: 'GET',
|
||||
headers:{"Authorization": 'Bearer ' + token}
|
||||
} )
|
||||
|
||||
27
src/login_close_helper.js
Normal file
@ -0,0 +1,27 @@
|
||||
(function() {
|
||||
browser.storage.local.get("url", (storage)=>{
|
||||
server_url = storage.url;
|
||||
if(!server_url){
|
||||
return
|
||||
}
|
||||
server_host = new URL(server_url).host;
|
||||
if(window.location.host==server_host){
|
||||
if (window.location.pathname=="/login"){
|
||||
browser.storage.local.get().then(async (storage) => {
|
||||
if(storage.attempt==0 && storage.login.length && storage.password.length){
|
||||
await browser.storage.local.set({
|
||||
attempt: 1
|
||||
})
|
||||
document.getElementsByName("login")[0].value=storage.login
|
||||
document.getElementsByName("password")[0].value=storage.password
|
||||
document.getElementsByName("loginform")[0].submit()
|
||||
}
|
||||
})
|
||||
}
|
||||
window.onbeforeunload = function() {
|
||||
browser.runtime.sendMessage("sync");
|
||||
}
|
||||
}
|
||||
})
|
||||
})();
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
browser.storage.local.get().then(async (storage) => {
|
||||
if(storage.attempt==0 && storage.login.length && storage.password.length){
|
||||
await browser.storage.local.set({
|
||||
attempt: 1
|
||||
})
|
||||
document.getElementsByName("login")[0].value=storage.login
|
||||
document.getElementsByName("password")[0].value=storage.password
|
||||
document.getElementsByName("loginform")[0].submit()
|
||||
}
|
||||
})
|
||||
@ -1,56 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="options.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="main">
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>Shaarli URL</span>
|
||||
<input id="url" type="text" name="url">
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>Shaarli API Token</span>
|
||||
<input id="token" type="text" name="token">
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>Shaarli User</span>
|
||||
<input id="login" type="text" name="login">
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>Shaarli Password</span>
|
||||
<input id="password" type="text" name="password">
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>Popup dimensions (px)</span>
|
||||
<input id="popupWidth" type="text" name="popupWidth"><input id="popupHeight" type="text" name="popupWidth"> (default : 900 x 600)
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>Address bar</span>
|
||||
<input id="pageAction" type="checkbox" name="pageAction" checked>
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span> </span>
|
||||
<button id="save-button" type="submit">Save preferences</button>
|
||||
</div>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="options.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="main">
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>Shaarli URL</span>
|
||||
<input id="url" type="text" name="url">
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>Shaarli API Token</span>
|
||||
<input id="token" type="text" name="token">
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>Shaarli User</span>
|
||||
<input id="login" type="text" name="login">
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>Shaarli Password</span>
|
||||
<input id="password" type="text" name="password">
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>Popup dimensions (px)</span>
|
||||
<input id="popupWidth" type="text" name="popupWidth"><input id="popupHeight" type="text" name="popupWidth">
|
||||
(default : 900 x 900)
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>Address bar</span>
|
||||
<input id="pageAction" type="checkbox" name="pageAction" checked>
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span> </span>
|
||||
<button id="save-button" type="submit">Save preferences</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>Icons made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a
|
||||
href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a></div>
|
||||
<script src="options.js"></script>
|
||||
</body>
|
||||
|
||||
<script src="options.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
@ -5,7 +5,7 @@ var storage = {
|
||||
url: '',
|
||||
pageAction: false,
|
||||
popupWidth: 900,
|
||||
popupHeight: 600,
|
||||
popupHeight: 900,
|
||||
login: "",
|
||||
password: "",
|
||||
token: "",
|
||||
|
||||