Skip to content

Commit

Permalink
bugs solved
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushikappani committed May 31, 2021
1 parent 9e1b521 commit dd7b823
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
let currentUrl;
chrome.tabs.query({
currentWindow: true,
active: true
}, function (tabs) {
console.log(tabs);
const tabUrl = document.getElementById('url')
if (tabUrl) {
currentUrl = tabs[0].url;
tabUrl.innerHTML = tabs[0].title
tabUrl.href = tabs[0].url
tabUrl.data = tabs[0].title
Expand All @@ -27,7 +29,7 @@ const fetch = () => {
template += `<tr>`
template += ` <th class="fav-th" scope="col"> <img class="favicon" src="${localData.favIconUrl}" alt=""></th>`
template += `<td style="max-width:350px;overflow:hidden"> <a target="_blank" href=${localData.url}>${localData.title}</a> </td>`
template += `<td><button data-key="saved-${localData.url}" class="btn delete"> <img src="x-circle-fill.svg"></button></td>`
template += `<td><button data-url="${localData.url}" data-key="saved-${localData.url}" class="btn delete"> <img src="x-circle-fill.svg"></button></td>`
template += `</tr>`
}
}
Expand Down Expand Up @@ -70,18 +72,18 @@ let buttons = document.querySelectorAll('.delete');
if (buttons) {
function removeThis(element) {
var dataKey = element.getAttribute('data-key');
var dataUrl = element.getAttribute('data-url');
dataUrl===currentUrl && chrome.browserAction.setIcon({
path: {
19: "icon.png"
}
});
localStorage.removeItem(dataKey);
location.reload();

}
for (let i = 0, len = buttons.length; i < len; i++) {
buttons[i].addEventListener('click', function (event) {
removeThis(this);
chrome.browserAction.setIcon({
path: {
19: "icon.png"
}
});
console.log(this)
})
}
Expand Down Expand Up @@ -117,7 +119,7 @@ let changeClass = () => {
btnGrp[i].classList.remove("selected");
}
}
};
};

changeClass();

Expand Down

0 comments on commit dd7b823

Please sign in to comment.