adding url to toot content

This commit is contained in:
theo1 2020-10-01 20:01:21 +02:00
parent a4a9163efc
commit 64db0492a5
4 changed files with 13 additions and 5 deletions

View File

@ -9,6 +9,7 @@
<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>
<span id='toot-url'></span>
<br> <br>
<script src="script.js"></script> <script src="script.js"></script>
</body> </body>

View File

@ -1,8 +1,10 @@
function tootInfo(message) { function tootInfo(message) {
tootContent = document.getElementById("toot-info").innerHTML tootContent = document.getElementById("toot-info").innerHTML
tootContent += " " tootContent += "\n\n"
tootContent += document.getElementById("toot-comment").value tootContent += document.getElementById("toot-comment").value
tootContent += " " tootContent += "\n\n"
tootContent += document.getElementById('toot-url').innerText
tootContent += "\n\n"
tootContent += document.getElementById("toot-hashtags").value tootContent += document.getElementById("toot-hashtags").value
url = "http://localhost:5000/toot" url = "http://localhost:5000/toot"
fetch(url, { fetch(url, {
@ -18,8 +20,9 @@ function tootInfo(message) {
} }
function handleResponse(message) { function handleResponse(message) {
document.getElementById("toot-info").innerHTML = message.artist + " - " + message.title + '\n\n' document.getElementById("toot-info").innerHTML = message.artist + " - " + message.title
document.getElementById("toot-hashtags").value = "#radio #np #musique #music" + '\n' document.getElementById("toot-hashtags").value = "#radio #np #musique #music" + '\n'
document.getElementById('toot-url').innerText = message.url
} }
function handleError(error) { function handleError(error) {

View File

@ -3,3 +3,7 @@
max-width: 100px; max-width: 100px;
white-space: pre-wrap; white-space: pre-wrap;
} }
/*
#toot-url {
visibility: hidden;
} */

View File

@ -1,5 +1,5 @@
browser.runtime.onMessage.addListener((data, sender, sendResponse) => { browser.runtime.onMessage.addListener((data, sender, sendResponse) => {
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, url: window.location.href})
}); });