Fully working addon
This commit is contained in:
parent
518e70ccb3
commit
4cc44fd78f
@ -5,7 +5,7 @@
|
||||
<link href="style.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
<span id="toot-info"></span>
|
||||
<span id="toot-info"></span><br>
|
||||
<input type="textarea" name="Comment" id="toot-comment" placeholder="Your comment here" cols="20" autofocus><br>
|
||||
<input type="text" id="toot-hashtags"></span><br>
|
||||
<button id="toot-button">Toot !</button><br><br>
|
||||
|
@ -1,12 +1,16 @@
|
||||
function tootInfo(message) {
|
||||
tootContent = message.artist + " - " + message.title
|
||||
url = "http://localhost:5000/toot?content=" + tootContent
|
||||
fetch(url)
|
||||
tootContent = document.getElementById("toot-info").innerHTML
|
||||
tootContent += " "
|
||||
tootContent += document.getElementById("toot-comment").value
|
||||
tootContent += " "
|
||||
tootContent += document.getElementById("toot-hashtags").value
|
||||
url = "http://localhost:5000/toot"
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(tootContent),
|
||||
})
|
||||
.then(function (response) {
|
||||
return response;
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log("Got response : " + response);
|
||||
return response.json();
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log("Error while tooting: " + error);
|
||||
@ -14,8 +18,8 @@ function tootInfo(message) {
|
||||
}
|
||||
|
||||
function handleResponse(message) {
|
||||
document.getElementById("toot-info").innerHTML += message.artist + " - " + message.title
|
||||
document.getElementById("toot-hashtags").value += "#radio #np #musique #music"
|
||||
document.getElementById("toot-info").innerHTML = message.artist + " - " + message.title
|
||||
document.getElementById("toot-hashtags").value = "#radio #np #musique #music"
|
||||
}
|
||||
|
||||
function handleError(error) {
|
||||
|
@ -1,8 +1,5 @@
|
||||
browser.runtime.onMessage.addListener((data, sender, sendResponse) => {
|
||||
console.log("Content script : " + data.command)
|
||||
deezerTitle = document.getElementsByClassName('track-link')[0].innerHTML
|
||||
deezerArtist = document.getElementsByClassName('track-link')[1].innerHTML
|
||||
sendResponse({title: deezerTitle, artist: deezerArtist})
|
||||
});
|
||||
|
||||
console.log("Content script loaded")
|
||||
});
|
@ -8,7 +8,7 @@
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["<all_urls>"],
|
||||
"matches": ["*://*.deezer.com/*"],
|
||||
"js": ["content_script.js"]
|
||||
}
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user