From 23f5e69140995514f60ef4c4d245346ff7606136 Mon Sep 17 00:00:00 2001
From: Michael Kaply <345868+mkaply@users.noreply.github.com>
Date: Fri, 26 Jun 2020 10:15:00 -0500
Subject: [PATCH] Initial checkin of Query AMO ID
---
extension/manifest.json | 16 +++++++++++++++
extension/popup.html | 35 ++++++++++++++++++++++++++++++++
extension/popup.js | 44 +++++++++++++++++++++++++++++++++++++++++
updates.json | 12 +++++++++++
4 files changed, 107 insertions(+)
create mode 100644 extension/manifest.json
create mode 100644 extension/popup.html
create mode 100644 extension/popup.js
create mode 100644 updates.json
diff --git a/extension/manifest.json b/extension/manifest.json
new file mode 100644
index 0000000..d21df0c
--- /dev/null
+++ b/extension/manifest.json
@@ -0,0 +1,16 @@
+{
+ "manifest_version": 2,
+ "name": "Query AMO Addon ID",
+ "version": "0.1",
+ "browser_action": {
+ "default_title": "Click here",
+ "default_popup": "popup.html"
+ },
+ "permissions": ["tabs"],
+ "browser_specific_settings": {
+ "gecko": {
+ "id": "queryamoid@kaply.com",
+ "update_url": "https://raw.githubusercontent.com/mkaply/queryamoid/main/updates.json"
+ }
+ }
+}
\ No newline at end of file
diff --git a/extension/popup.html b/extension/popup.html
new file mode 100644
index 0000000..b5dcecc
--- /dev/null
+++ b/extension/popup.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/extension/popup.js b/extension/popup.js
new file mode 100644
index 0000000..6e50cde
--- /dev/null
+++ b/extension/popup.js
@@ -0,0 +1,44 @@
+browser.tabs.query({
+ active: true,
+ lastFocusedWindow: true
+}).then(function(tabs) {
+let url = new URL(tabs[0].url);
+if (url.host != "addons.mozilla.org") {
+ showMessage("This extension only works on addons.mozilla.org.");
+ return;
+}
+let splitPath = url.pathname.split("/");
+if (splitPath[3] != "addon") {
+ showMessage("This extension only works on addon pages.");
+ return;
+}
+let slug = splitPath[4];
+fetch(`https://addons.mozilla.org/api/v4/addons/addon/${slug}/`)
+.then((response) => {
+ return response.json();
+})
+.then((data) => {
+ document.getElementById("guid").textContent = data.guid;
+ document.getElementById("url").textContent = `https://addons.mozilla.org/firefox/downloads/latest/${slug}/latest.xpi`;
+});})
+
+document.getElementById("copy_guid").addEventListener("click", function() {
+ var copyText = document.getElementById("clipboard");
+ copyText.value = document.getElementById("guid").textContent;
+ copyText.select();
+ document.execCommand("copy");
+});
+
+document.getElementById("copy_url").addEventListener("click", function() {
+ var copyText = document.getElementById("clipboard");
+ copyText.value = document.getElementById("url").textContent;
+ copyText.select();
+ document.execCommand("copy");
+});
+
+function showMessage(message) {
+ let messageElement = document.getElementById("message");
+ messageElement.style.display = "block";
+ messageElement.textContent = message;
+ document.getElementById("addon").style.display = "none";
+}
\ No newline at end of file
diff --git a/updates.json b/updates.json
new file mode 100644
index 0000000..0566c56
--- /dev/null
+++ b/updates.json
@@ -0,0 +1,12 @@
+{
+ "addons": {
+ "queryamoid@kaply.com": {
+ "updates": [
+ {
+ "version": "0.1",
+ "update_link": "https://github.com/mkaply/queryamoid/releases/download/0.1/queryamoid-0.1.xpi"
+ }
+ ]
+ }
+ }
+ }
\ No newline at end of file