diff --git a/hasher.js b/hasher.js index f9483b4..593874f 100644 --- a/hasher.js +++ b/hasher.js @@ -11,11 +11,17 @@ var tabs = { }; /* - * Copy to clipboard + * Copy to clipboard (Clipboard API with execCommand fallback) */ function copyToClipboard(id) { - $("#"+id).select(); - document.execCommand('copy'); + var el = document.getElementById(id); + var text = el ? (el.value || el.textContent || "") : ""; + if (navigator.clipboard && navigator.clipboard.writeText) { + navigator.clipboard.writeText(text); + } else { + $("#" + id).select(); + document.execCommand("copy"); + } } diff --git a/manifest.json b/manifest.json index d370b11..14fc4b2 100644 --- a/manifest.json +++ b/manifest.json @@ -1,19 +1,20 @@ { "name": "Hasher", - "version": "1.3.2", - "manifest_version": 2, + "version": "1.3.3", + "manifest_version": 3, "description": "Developer's toolbox. Calculates MD5, SHA-1, SHA-2, IP/Subnet, URL decode, Base64 and more", "offline_enabled": true, "permissions": [ - "clipboardWrite", "tabs" + "clipboardWrite", + "tabs" ], - "browser_action": { + "action": { "default_icon": "images/icon.png", "default_popup": "popup.html" }, "icons": { - "16": "images/icon16.png", - "48": "images/icon48.png", + "16": "images/icon16.png", + "48": "images/icon48.png", "128": "images/icon128.png" } } diff --git a/popup.js b/popup.js index 36e1685..c325329 100644 --- a/popup.js +++ b/popup.js @@ -1,20 +1,8 @@ $(document).ready(function() { -/* - * I decided to leave popout button on the popout page - * - if (typeof chrome.extension != "undefined") { - if (chrome.extension.getBackgroundPage().separatePopup == true) { - $("#popup").hide(); - } else { - $("#popup").show(); - } - } -*/ - /* * Events registration - */ + */ $("#input").keyup(function () { hasher.update(); }); @@ -24,18 +12,9 @@ $(document).ready(function() { // Open separate window (pop-out) $("#button-popout").click(function () { - if (typeof chrome.extension != "undefined") { - //chrome.extension.getBackgroundPage().separatePopup = true; -/* - chrome.windows.create({ - url: 'popup.html', - type: 'popup', - width: 700, - height: 800 - }); -*/ + if (typeof chrome.runtime !== "undefined" && chrome.runtime.getURL) { chrome.tabs.create({ - url: 'popup.html' + url: chrome.runtime.getURL("popup.html") }); } });