Compare commits
13 commits
Author | SHA1 | Date | |
---|---|---|---|
d9bf5dd780 | |||
92290ff70c | |||
35964539b0 | |||
8a04b7ebe6 | |||
f02ab7fc00 | |||
dec97b81b7 | |||
49383631cd | |||
e299e9effe | |||
bca5ad2396 | |||
df4f3c409f | |||
6d5d9ae128 | |||
7caa357e35 | |||
3fbfebb911 |
4 changed files with 158 additions and 39 deletions
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
liberapay: dovicowan
|
20
README.md
Normal file
20
README.md
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# eBay Item Remover
|
||||||
|
This Chrome extension allows you to hide items from eBay search results.
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
* Extension currently only works in Chrome
|
||||||
|
* Extension currently only works for eBay UK (https://ebay.co.uk) and eBay US (https://ebay.com)
|
||||||
|
* Currently, the only way to make a hidden item show again is to uninstall and reinstall the extension. This will reset it and make all items previously hidden show up in search results again.
|
||||||
|
* **IMPORTANT: If you currently have version 0.0.1, you must remove the extension before installing the new update**
|
||||||
|
|
||||||
|
## Installation / Upgrade Instructions
|
||||||
|
### 1. Download extension
|
||||||
|
1. Go to the [Releases](https://github.com/dcowan-london/remove-ebay-items/releases), find the latest realse and expand the Assests section.
|
||||||
|
1. Right click on "extension.crx" and click "Save link as...". Choose a location on your computer (doesn't matter where).
|
||||||
|
|
||||||
|
### 2. Install extension
|
||||||
|
1. Go to [chrome://extensions](chrome://extensions). Toggle "Developer mode" to on in the top right.
|
||||||
|
1. Click and drag "extension.crx" from the downloads bar in the bottom left of your screen into the middle of the page.
|
||||||
|
|
||||||
|
#### If this is a new install
|
||||||
|
3. Click "Add extension" in the popup.
|
|
@ -1,10 +1,3 @@
|
||||||
/* chrome.browserAction.onClicked.addListener(function () {
|
|
||||||
console.log("Test");
|
|
||||||
|
|
||||||
// let title = browser.i18n.getMessage("notificationTitle");
|
|
||||||
// let content = browser.i18n.getMessage("notificationContent", message.url);
|
|
||||||
}) */
|
|
||||||
|
|
||||||
chrome.runtime.onInstalled.addListener(function(details) {
|
chrome.runtime.onInstalled.addListener(function(details) {
|
||||||
|
|
||||||
if(details.reason == "install"){
|
if(details.reason == "install"){
|
||||||
|
@ -20,23 +13,58 @@ chrome.runtime.onInstalled.addListener(function(details) {
|
||||||
|
|
||||||
chrome.action.onClicked.addListener(async tab => {
|
chrome.action.onClicked.addListener(async tab => {
|
||||||
var hiddenItemsList;
|
var hiddenItemsList;
|
||||||
|
|
||||||
chrome.storage.sync.get(['hiddenItemsList'], function(result) {
|
|
||||||
hiddenItemsList = JSON.parse(result.hiddenItemsList);
|
|
||||||
hiddenItemsList = Object.values(hiddenItemsList);
|
|
||||||
console.log(hiddenItemsList);
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
hiddenItemsList = await getHiddenItemsList();
|
||||||
await chrome.scripting.insertCSS({
|
|
||||||
target: {
|
await removeItems();
|
||||||
tabId: tab.id,
|
|
||||||
},
|
addButton();
|
||||||
css: `.s-item a.s-item__link { border-style: solid; }`
|
|
||||||
|
readdItem();
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// await chrome.scripting.insertCSS({
|
||||||
|
// target: {
|
||||||
|
// tabId: tab.id,
|
||||||
|
// },
|
||||||
|
// css: `.s-item a.s-item__link { border-style: solid; }`
|
||||||
|
// });
|
||||||
|
// } catch (error) {
|
||||||
|
// console.error('CSS insert failed! ' + error);
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
|
||||||
|
chrome.webNavigation.onCompleted.addListener(function() {
|
||||||
|
chrome.notifications.create({
|
||||||
|
"type": "basic",
|
||||||
|
"iconUrl": "icons/ebay-48.png",
|
||||||
|
"title": 'eBay Item Remover',
|
||||||
|
"message": "eBay Item Remover is running - and you've just loaded an eBay page!"
|
||||||
|
});
|
||||||
|
}, {
|
||||||
|
url: [{
|
||||||
|
urlMatches : 'https://www.ebay.co.uk/'
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
|
||||||
|
const getHiddenItemsList = async () => {
|
||||||
|
var hiddenItemsList;
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
chrome.storage.sync.get(['hiddenItemsList'], async (result) => {
|
||||||
|
hiddenItemsList = JSON.parse(result.hiddenItemsList);
|
||||||
|
hiddenItemsList = Object.values(hiddenItemsList);
|
||||||
|
|
||||||
|
resolve(hiddenItemsList);
|
||||||
});
|
});
|
||||||
} catch (error) {
|
});
|
||||||
console.error('CSS insert failed! ' + error);
|
}
|
||||||
}
|
|
||||||
|
async function removeItems() {
|
||||||
|
let queryOptions = { active: true, lastFocusedWindow: true };
|
||||||
|
let [tab] = await chrome.tabs.query(queryOptions);
|
||||||
|
|
||||||
|
let hiddenItemsList = await getHiddenItemsList();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await chrome.scripting.executeScript({
|
await chrome.scripting.executeScript({
|
||||||
|
@ -53,14 +81,14 @@ chrome.action.onClicked.addListener(async tab => {
|
||||||
if(hiddenItemsList.includes(parseInt(itemID))) {
|
if(hiddenItemsList.includes(parseInt(itemID))) {
|
||||||
console.log("Item " + itemID + " is in removelist!");
|
console.log("Item " + itemID + " is in removelist!");
|
||||||
console.log(element.closest('.s-item'));
|
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 {
|
} else {
|
||||||
let parent = element.closest('.s-item');
|
let parent = element.closest('.s-item');
|
||||||
|
|
||||||
console.log(itemID);
|
console.log(itemID);
|
||||||
console.log(element.closest('.s-item'));
|
console.log(element.closest('.s-item'));
|
||||||
|
|
||||||
parent.insertAdjacentHTML('beforeend', '<span class="s-item__watchheart at-corner s-item__watchheart--watch" style="right: 30px; bottom: 10px;"><a aria-label="remove item" href="#"><span class="s-item__watchheart-icon"><svg class="icon icon--save-small" focusable="false" aria-hidden="true"><circle cx="10" cy="9" r="6.5" stroke="black" stroke-width="2" fill="none"></circle></svg><svg class="icon icon--save-selected-small" focusable="false" aria-hidden="true"><use xlink:href="#icon-save-selected-small"></use></svg></span></a></span>')
|
parent.insertAdjacentHTML('beforeend', '<span class="s-item__watchheart at-corner s-item__watchheart--watch ebayitemremover-extension_removeitem" ebayitemremover-extension_itemid=' + itemID + ' style="right: 30px; bottom: 10px;"><a aria-label="remove item" href="#"><span class="s-item__watchheart-icon"><svg class="icon icon--save-small" focusable="false" aria-hidden="true"><circle cx="10" cy="9" r="6.5" stroke="black" stroke-width="2" fill="none"></circle></svg><svg class="icon icon--save-selected-small" focusable="false" aria-hidden="true"><use xlink:href="#icon-save-selected-small"></use></svg></span></a></span>')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -70,17 +98,87 @@ chrome.action.onClicked.addListener(async tab => {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Get HREFs failed! ' + error);
|
console.error('Get HREFs failed! ' + error);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
chrome.webNavigation.onCompleted.addListener(function() {
|
async function addButton() {
|
||||||
chrome.notifications.create({
|
let queryOptions = { active: true, lastFocusedWindow: true };
|
||||||
"type": "basic",
|
let [tab] = await chrome.tabs.query(queryOptions);
|
||||||
"iconUrl": "icons/ebay-48.png",
|
|
||||||
"title": 'eBay Item Remover',
|
let hiddenItemsList = await getHiddenItemsList();
|
||||||
"message": "eBay Item Remover is running - and you've just loaded an eBay page!"
|
|
||||||
});
|
try {
|
||||||
}, {
|
await chrome.scripting.executeScript({
|
||||||
url: [{
|
target: {
|
||||||
urlMatches : 'https://www.ebay.co.uk/'
|
tabId: tab.id,
|
||||||
}]
|
},
|
||||||
});
|
args: [ hiddenItemsList ],
|
||||||
|
func: (hiddenItemsList) => {
|
||||||
|
Array.from(document.getElementsByClassName('ebayitemremover-extension_removeitem')).forEach(element => {
|
||||||
|
element.addEventListener('click', (event) => {
|
||||||
|
let parent = event.target.closest('.ebayitemremover-extension_removeitem');
|
||||||
|
let itemID = parseInt(parent.getAttribute('ebayitemremover-extension_itemid'));
|
||||||
|
|
||||||
|
console.log(itemID + ' clicked');
|
||||||
|
|
||||||
|
let sureRemove = confirm('Sure you want to remove this item?');
|
||||||
|
|
||||||
|
if(sureRemove) {
|
||||||
|
hiddenItemsList[hiddenItemsList.length] = itemID;
|
||||||
|
} else {
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
chrome.storage.sync.set( {'hiddenItemsList': JSON.stringify(hiddenItemsList)}, function() {
|
||||||
|
// parent.innerHTML = "REMOVED BY EBAY ITEM REMOVER";
|
||||||
|
alert("Done\nYou need to click the extension icon for this to take effect")
|
||||||
|
} );
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error adding removal button! " + error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function readdItem() {
|
||||||
|
let queryOptions = { active: true, lastFocusedWindow: true };
|
||||||
|
let [tab] = await chrome.tabs.query(queryOptions);
|
||||||
|
|
||||||
|
let hiddenItemsList = await getHiddenItemsList();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await chrome.scripting.executeScript({
|
||||||
|
target: {
|
||||||
|
tabId: tab.id,
|
||||||
|
},
|
||||||
|
args: [ hiddenItemsList ],
|
||||||
|
func: (hiddenItemsList) => {
|
||||||
|
Array.from(document.getElementsByClassName('ebayitemremover-extension_readditem')).forEach(element => {
|
||||||
|
element.addEventListener('click', (event) => {
|
||||||
|
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();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error adding readd! " + error);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "eBay Item Remove - DEVELOPMENT BUILD",
|
"name": "eBay Item Remove - DEVELOPMENT BUILD",
|
||||||
"version": "0.0.2",
|
"version": "0.0.6",
|
||||||
|
|
||||||
"description": "Remove items you don't want to see from eBay",
|
"description": "Remove items you don't want to see from eBay",
|
||||||
|
|
||||||
|
@ -22,5 +22,5 @@
|
||||||
|
|
||||||
"permissions": [ "notifications", "webNavigation", "scripting", "storage" ],
|
"permissions": [ "notifications", "webNavigation", "scripting", "storage" ],
|
||||||
|
|
||||||
"host_permissions": [ "*://*.ebay.co.uk/*" ]
|
"host_permissions": [ "*://*.ebay.co.uk/*", "*://*.ebay.com/*" ]
|
||||||
}
|
}
|
Loading…
Reference in a new issue