readd item

This commit is contained in:
Dovi Cowan 2022-08-01 23:36:28 +01:00
parent 35964539b0
commit 92290ff70c
No known key found for this signature in database
GPG key ID: CC028FE44C985E37

View file

@ -145,19 +145,35 @@ async function addButton() {
} }
} }
async function readdItem(itemID) { async function readdItem() {
let queryOptions = { active: true, lastFocusedWindow: true }; let queryOptions = { active: true, lastFocusedWindow: true };
let [tab] = await chrome.tabs.query(queryOptions); let [tab] = await chrome.tabs.query(queryOptions);
let hiddenItemsList = await getHiddenItemsList();
try { try {
await chrome.scripting.executeScript({ await chrome.scripting.executeScript({
target: { target: {
tabId: tab.id, tabId: tab.id,
}, },
func: () => { args: [ hiddenItemsList ],
func: (hiddenItemsList) => {
Array.from(document.getElementsByClassName('ebayitemremover-extension_readditem')).forEach(element => { Array.from(document.getElementsByClassName('ebayitemremover-extension_readditem')).forEach(element => {
element.addEventListener('click', (event) => { element.addEventListener('click', (event) => {
let itemID = parseInt(parent.getAttribute('ebayitemremover-extension_itemid')); let itemID = parseInt(event.currentTarget.getAttribute('ebayitemremover-extension_itemid'));
const index = hiddenItemsList.indexOf(itemID);
try {
hiddenItemsList.splice(index, 1);
} catch (error) {
alert("failed removing " + itemID);
}
chrome.storage.sync.set( {'hiddenItemsList': JSON.stringify(hiddenItemsList)}, function() {
alert("Done\nYou need to reload the page for this to take effect");
});
event.preventDefault();
event.preventDefault();
}) })
}); });
} }