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