start on readd

This commit is contained in:
Dovi Cowan 2022-08-01 23:24:47 +01:00
parent 8a04b7ebe6
commit 35964539b0
No known key found for this signature in database
GPG key ID: CC028FE44C985E37

View file

@ -20,6 +20,8 @@ chrome.action.onClicked.addListener(async tab => {
addButton();
readdItem();
// try {
// await chrome.scripting.insertCSS({
// target: {
@ -79,7 +81,7 @@ async function removeItems() {
if(hiddenItemsList.includes(parseInt(itemID))) {
console.log("Item " + itemID + " is in removelist!");
console.log(element.closest('.s-item'));
element.closest('.s-item').innerHTML = 'REMOVED BY EBAY ITEM REMOVER';
element.closest('.s-item').innerHTML = "REMOVED BY EBAY ITEM REMOVER <a href='#' class='ebayitemremover-extension_readditem' ebayitemremover-extension_itemid='" + itemID + "'>Readd</a>";
} else {
let parent = element.closest('.s-item');
@ -142,3 +144,25 @@ async function addButton() {
console.log("Error adding removal button! " + error);
}
}
async function readdItem(itemID) {
let queryOptions = { active: true, lastFocusedWindow: true };
let [tab] = await chrome.tabs.query(queryOptions);
try {
await chrome.scripting.executeScript({
target: {
tabId: tab.id,
},
func: () => {
Array.from(document.getElementsByClassName('ebayitemremover-extension_readditem')).forEach(element => {
element.addEventListener('click', (event) => {
let itemID = parseInt(parent.getAttribute('ebayitemremover-extension_itemid'));
})
});
}
})
} catch (error) {
console.log("Error adding readd! " + error);
}
}