-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpopup.js
70 lines (64 loc) · 2.46 KB
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// document.addEventListener('DOMContentLoaded', function() {
// var checkPageButton = document.getElementById('checkPage');
// checkPageButton.addEventListener('click', function() {
// chrome.tabs.getSelected(null, function(tab) {
// d = document;
// var f = d.createElement('form');
// f.action = 'http://gtmetrix.com/analyze.html?bm';
// f.method = 'post';
// var i = d.createElement('input');
// i.type = 'hidden';
// i.name = 'url';
// i.value = tab.url;
// f.appendChild(i);
// d.body.appendChild(f);
// f.submit();
// });
// }, false);
// }, false);
//create eventListener for content DOM content
//fetch youtube API, store into a var
//fetch a playlist of some kind for now
//display first video of playlist and name of artist/ name of audio content
//add Click events listeners for buttons
//get all buttons to work with data as they should
//when play button is clicked, display pause button instead
//when we reach the end of playlist, start at the top of the playlist and display play button again
// document.addEventListener('DOMContentLoaded', function() {
// fetch("https://top-10-spotify.p.rapidapi.com/", {
// "method": "GET",
// "headers": {
// "x-rapidapi-key": "SIGN-UP-FOR-KEY",
// "x-rapidapi-host": "top-10-spotify.p.rapidapi.com"
// }
// }).then(response => {
// response.json();
// console.log('hey')
// }).then((data) => {
// //where we enter our logic
// //loop through array
// let container = document.querySelector('container');
// for(let i = 0; i < data.length; i+=1){
// container.appendChild(data[i]["name"]);
// // console.log(data[i]);
// }
// //if at the first index, the play and next button should only work
// //if at the last index, the next button should take us to beginning of array
// }).catch(err => {
// console.error(err);
// });
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
if (request.message === "clicked_browser_action") {
// var firstHref = $("a[href^='http']").eq(0).attr("href");
let firstHref = document.querySelectorAll("a[href='http://youtube.com']");
//point to youtube?
console.log(firstHref);
chrome.runtime.sendMessage({ "message": "open_new_tab", "url": firstHref });
}
});
// {
// "name":" Dakiti by Bad Bunny, Jhay Cortez "
// "pos":1
// "urlvideo":"https://www.youtube.com/watch?v=91vECNhvmMY"
// }