From 6e9b70eb0113fd10a1f1fe25b345fa5762e94055 Mon Sep 17 00:00:00 2001 From: Kartik Soneji Date: Sat, 11 Jan 2020 00:11:00 +0530 Subject: [PATCH 01/10] Added permission for storage, Fixed formatting. --- manifest.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/manifest.json b/manifest.json index d9d39de..61e01fe 100644 --- a/manifest.json +++ b/manifest.json @@ -4,16 +4,24 @@ "version": "0.5", "manifest_version": 2, "minimum_chrome_version": "18.0", + + "permissions": [ + "storage" + ], + "icons": { "24": "gfx/icon_24.png", "128": "gfx/icon_128.png" }, + "devtools_page": "devtools.html", + "background": { "scripts": [ "js/background.js" ], "persistent": false }, + "content_security_policy": "script-src 'self' https://apis.google.com https://platform.twitter.com https://www.facebook.com; object-src 'self'" } From 197faab1dc57b230c5eed145546fe34363609262 Mon Sep 17 00:00:00 2001 From: Kartik Soneji Date: Sat, 11 Jan 2020 00:15:11 +0530 Subject: [PATCH 02/10] Switched localstorage to chrome.storage.local as per FIXME Resolved as Bug is fixed: "FIXME Can be replaced with chrome.storage.local as soon as http://crbug.com/178618 will be resolved" --- js/background.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/js/background.js b/js/background.js index c1dbe33..651bd6c 100644 --- a/js/background.js +++ b/js/background.js @@ -1,17 +1,19 @@ /* Allows to read, change and override settings kept in localStorage - - FIXME Can be replaced with chrome.storage.local as soon as http://crbug.com/178618 will be resolved - FIXME Can be replaced with localStorage on the panel page as soon as http://crbug.com/319328 will be resolved */ -chrome.runtime.onMessage.addListener(function (message, sender, callback) { +chrome.runtime.onMessage.addListener((message, sender, callback) => { "use strict"; - if (message.name === 'getSettings') { + if(message.name === 'getSettings') callback(localStorage); - } else if (message.name === 'setSettings') { - localStorage = message.data; - } else if (message.name === 'changeSetting') { - localStorage[message.item] = message.value; + + else if(message.name === 'setSettings') + chrome.storage.local.set(message.data); + + else if(message.name === 'changeSetting') { + let data = {}; + data[message.item] = message.value; + + chrome.storage.local.set(data); } }); From 24e52e2e83c053df7eb4df76f2dc898352776e19 Mon Sep 17 00:00:00 2001 From: Kartik Soneji Date: Sat, 11 Jan 2020 00:18:30 +0530 Subject: [PATCH 03/10] Fixed "Send to JsBin". Needed an empty input with name = `js` as per JsBin API. --- panel.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/panel.html b/panel.html index e5fb273..4f32c51 100644 --- a/panel.html +++ b/panel.html @@ -109,6 +109,7 @@

+
@@ -116,10 +117,12 @@

-
+ +
+
From 792e410a6ccccf7671674aa2713262ec024eaf2f Mon Sep 17 00:00:00 2001 From: Kartik Soneji Date: Sat, 11 Jan 2020 17:30:50 +0530 Subject: [PATCH 04/10] Fixed "Send to JsBin" --- panel.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/panel.html b/panel.html index 4f32c51..dd1ed2d 100644 --- a/panel.html +++ b/panel.html @@ -111,9 +111,15 @@

-
+ + + + + + +
From 6caa8bcaebf0e89bdcf85f27b52d7b1a1120b655 Mon Sep 17 00:00:00 2001 From: Kartik Soneji Date: Sat, 11 Jan 2020 17:32:06 +0530 Subject: [PATCH 05/10] Added permission for JsBin CORS Request --- manifest.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 61e01fe..4837307 100644 --- a/manifest.json +++ b/manifest.json @@ -6,8 +6,9 @@ "minimum_chrome_version": "18.0", "permissions": [ - "storage" - ], + "storage", + "https://jsbin.com/" + ], "icons": { "24": "gfx/icon_24.png", From e8003816ed614b3559169151a380e55e501cc01e Mon Sep 17 00:00:00 2001 From: Kartik Soneji Date: Sat, 11 Jan 2020 17:35:09 +0530 Subject: [PATCH 06/10] Fixed "Open in JsBin" JsBin has a CSRF Token that needs to be included to allow creation. --- js/panel.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/js/panel.js b/js/panel.js index c956473..afad51f 100644 --- a/js/panel.js +++ b/js/panel.js @@ -56,9 +56,25 @@ jsbinForm.on('submit', function () { var htmlInput = jsbinForm.find('input[name=html]'); var cssInput = jsbinForm.find('input[name=css]'); + var csrfToken = jsbinForm.find('input[name=_csrf]'); - htmlInput.val(encodeURIComponent(htmlTextarea.val())); - cssInput.val(encodeURIComponent(cssTextarea.val())); + htmlInput.val(htmlTextarea.val()); + cssInput.val(cssTextarea.val()); + + if(!csrfToken.val()){ + fetch("https://jsbin.com") + .then(e => e.text()) + .then(e => { + let token = e.match(/name="_csrf" value="(.*?)"/)[1]; + csrfToken.val(token); + + console.log(token); + + jsbinForm.find('[type=submit]').click(); + }); + + e.preventDefault(); + } }); //Event listeners From 088e26af654fe26ae7641b920e37d6779728193b Mon Sep 17 00:00:00 2001 From: Kartik Soneji Date: Sat, 11 Jan 2020 17:53:33 +0530 Subject: [PATCH 07/10] Removed console.log --- js/panel.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/js/panel.js b/js/panel.js index afad51f..6b5e8c0 100644 --- a/js/panel.js +++ b/js/panel.js @@ -67,9 +67,6 @@ .then(e => { let token = e.match(/name="_csrf" value="(.*?)"/)[1]; csrfToken.val(token); - - console.log(token); - jsbinForm.find('[type=submit]').click(); }); From b6e1936451fa6c9671c873ab5b84f9aa8737fba0 Mon Sep 17 00:00:00 2001 From: Kartik Soneji Date: Sat, 11 Jan 2020 18:52:36 +0530 Subject: [PATCH 08/10] Added "Copy to Clipboard" button listener. --- js/panel.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/panel.js b/js/panel.js index 6b5e8c0..8379a61 100644 --- a/js/panel.js +++ b/js/panel.js @@ -16,6 +16,7 @@ codepenForm = $('#codepen-form'), jsfiddleForm = $('#jsfiddle-form'), jsbinForm = $('#jsbin-form'), + copyToClipboard = $('#copy-to-clipboard'), propertiesCleanUpInput = $('#properties-clean-up'), removeDefaultValuesInput = $('#remove-default-values'), @@ -73,6 +74,11 @@ e.preventDefault(); } }); + + copyToClipboard.on('click', function () { + var text = htmlTextarea.val() + "\n\n\n" + cssTextarea.val(); + navigator.clipboard.writeText(text); + }); //Event listeners From 75faaf051335029f6e7fbaabffdb898835d8e2a8 Mon Sep 17 00:00:00 2001 From: Kartik Soneji Date: Sat, 11 Jan 2020 18:53:56 +0530 Subject: [PATCH 09/10] Center aligned buttons --- css/panel.css | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/css/panel.css b/css/panel.css index 7605592..19c0d38 100644 --- a/css/panel.css +++ b/css/panel.css @@ -16,11 +16,7 @@ top: 5px; } -#export-buttons-row div:first-child { - text-align: right; -} - -#export-buttons-row div:nth-child(2) { +#export-buttons-row div { text-align: center; } From b6b86267195182a73c48c3c396e3325f6c928518 Mon Sep 17 00:00:00 2001 From: Kartik Soneji Date: Sat, 11 Jan 2020 18:55:03 +0530 Subject: [PATCH 10/10] Added "Copy to Clipboard" button --- panel.html | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/panel.html b/panel.html index dd1ed2d..ded733e 100644 --- a/panel.html +++ b/panel.html @@ -103,14 +103,14 @@

-
+
-
+
@@ -124,13 +124,19 @@

-
+
+
+ +
+