-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
body { | ||
font-family: sans-serif; | ||
} | ||
#message { | ||
display: none; | ||
} | ||
#clipboard { | ||
position: absolute; | ||
left: 0; | ||
top:0; | ||
opacity: 0; | ||
} | ||
button { | ||
margin: 5px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="message"></div> | ||
<div id="addon"> | ||
<div> | ||
<span id="guid"></span><button id="copy_guid">Copy</button> | ||
</div> | ||
<div> | ||
<span id="url"></span><button id="copy_url">Copy</button> | ||
</div> | ||
<input type="text" id="clipboard"> | ||
</div> | ||
</body> | ||
<script src="popup.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
] | ||
} | ||
} | ||
} |