Skip to content

Commit

Permalink
move currentLocation into event listener
Browse files Browse the repository at this point in the history
  • Loading branch information
bbilly1 committed Nov 29, 2022
1 parent b34d8a8 commit 030fb2d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions extension/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,17 @@ function buildButtonDiv() {

function buildSubLink(channelContainer) {
var subLink = document.createElement("span");
var currentLocation = window.location.href;
subLink.innerText = "Subscribe";
subLink.addEventListener('click', e => {
e.preventDefault();
var currentLocation = window.location.href;
console.log("subscribe to: " + currentLocation);
sendUrl(currentLocation, "subscribe", subLink);
});
subLink.addEventListener("mouseover", e => {
let subText
if (window.location.pathname == "/watch") {
var currentLocation = window.location.href;
subText = currentLocation;
} else {
subText = channelContainer.querySelector("#text").textContent;
Expand All @@ -156,17 +157,18 @@ function buildSpacer() {

function buildDlLink(channelContainer) {
var dlLink = document.createElement("span");
var currentLocation = window.location.href;
dlLink.innerHTML = downloadIcon;

dlLink.addEventListener('click', e => {
e.preventDefault();
var currentLocation = window.location.href;
console.log("download: " + currentLocation)
sendUrl(currentLocation, "download", dlLink);
});
dlLink.addEventListener("mouseover", e => {
let subText
if (window.location.pathname == "/watch") {
var currentLocation = window.location.href;
subText = currentLocation;
} else {
subText = channelContainer.querySelector("#text").textContent;
Expand Down Expand Up @@ -366,7 +368,6 @@ const throttle = (callback, time) => {
if (throttleBlock) return;
throttleBlock = true;
setTimeout(() => {
console.log("observer hit");
callback();
throttleBlock = false;
}, time);
Expand Down

0 comments on commit 030fb2d

Please sign in to comment.