Browse Source

use window.open so that shaarli may close it (on chrome)

Andrew Dolgov 4 weeks ago
parent
commit
22010a9929
2 changed files with 11 additions and 9 deletions
  1. 10 8
      js/background.js
  2. 1 1
      manifest.json

+ 10 - 8
js/background.js

@@ -7,21 +7,23 @@ function post_to_shaarli(url, title) {
 
 			if (settings.url) {
 				const popup_url = settings.url + '/?post=' + encodeURIComponent(url) +
-					'&title=' + encodeURIComponent(title) +
-					'&source=bookmarklet';
+					'&title=' + encodeURIComponent(title);
 
 				const width = 600;
 				const height = 400;
 				const left = screen.width/2 - width/2;
 				const top = screen.height/2 - height/2;
 
-/*				window.open(popup_url,
-					'_save_to_shaarli',
-					`left=${left},top=${top},width=${width},height=${height},
-					status=no,location=no,toolbar=no,directories=no,menubar=no,resizable=yes`);  */
-
-				chrome.windows.create({url: popup_url, type: 'popup', width: width, height: height, left: left, top: top});
+				if (typeof browser == 'undefined') {
+					window.open(popup_url + "&source=bookmarklet",
+						'save_to_shaarli',
+						`left=${left},top=${top},width=${width},height=${height},
+						status=no,location=no,toolbar=no,directories=no,menubar=no,resizable=yes`);
 
+				} else {
+					chrome.windows.create({url: popup_url, type: 'popup',
+						width: width, height: height, left: left, top: top});
+				}
 
 				}
 		} else {

+ 1 - 1
manifest.json

@@ -19,5 +19,5 @@
 		"page": "options.html"
 	},
    "permissions": [ "contextMenus", "storage", "activeTab" ],
-   "version": "0.4"
+   "version": "0.5"
 }