Last active
January 31, 2023 11:18
-
-
Save cyphunk/73bb3f65076f171d83d96a8afa8975a0 to your computer and use it in GitHub Desktop.
make-keinanzeigen-usable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name make ebay keinanzeigen usable | |
// @namespace github.com/cyphunk | |
// @version 1970.1.1 | |
// @match https://*.ebay-kleinanzeigen.de/* | |
// @run-at document-end | |
// @grant none | |
// @author cyphunk | |
// @icon https://ebay-kleinanzeigen.de//favicon.ico | |
// @description make ebay keinanzeigen usable. attempts to fade duplicates and items you have already seen once. has a high false possitive rate with current configuration where an item is keyed by only zipcode and price. I'd rather have higher false-positives and have adverts I miss then see an advert reposted with just a different title. This can bechanged though, see code below to change 'TAG' | |
// @homepage https://gist.githubusercontent.com/cyphunk/73bb3f65076f171d83d96a8afa8975a0/ | |
// @updateURL https://gist.githubusercontent.com/cyphunk/73bb3f65076f171d83d96a8afa8975a0/raw/make-keinanzeigen-usable.js | |
// ==/UserScript== | |
// - removes all "pro" adverts | |
// - attempts to deduplicate | |
// this last attempts to avoid the issue of ebay-kleinanzeigen sellers | |
// always reposting same adds, making it impossible to monitor for new finds | |
(function(window, undefined ){ | |
var tmp; // can use tmp to inspect problems | |
console.log('REMOVE ELEMENTS WITH "pro" TAG') | |
// push parent elems into an array first so we can fully delete | |
var tmparr=[] | |
document.querySelectorAll('.badge-hint-pro-small-srp') | |
.forEach( elem => { | |
tmp=elem.closest('li'); | |
console.log(tmp); | |
tmparr.push(tmp) | |
}); | |
tmparr.forEach(elem=>elem.remove()) | |
console.log('REMOVE DUPLICATES & REPOSTS') | |
console.log('if the localStorage structure is saved between runs this may also work to remove reposts') | |
console.log('currently keying with tags based on Zipcode + price.') | |
// do not use .ad-listitem class because deleted "pro" entries still show there | |
// to be absolutely sure we get valid items lets just get all with zipcode location icon | |
var tmparr2=[] | |
document.querySelectorAll('.icon-pin') | |
.forEach( elem => { | |
tmp=elem.closest('li'); | |
console.log(tmp); | |
tmparr2.push(tmp); | |
}); | |
// setup storage | |
var tags=[] | |
// delete localStorage.tags | |
if (localStorage.tags == undefined ) { | |
localStorage.tags=JSON.stringify([]); | |
} | |
var localStorageTags = JSON.parse(localStorage.tags); | |
tmparr2.forEach(elem=>{ | |
tmp=elem | |
var zip=tmp.querySelector('.icon-pin').closest('div').innerText; | |
var price=tmp.querySelector('.aditem-main--middle--price-shipping--price').innerText; | |
var title=tmp.querySelector('h2').innerText; | |
var desc=tmp.querySelector('.aditem-main--middle--description').innerText; | |
// console.log('price zip:',price,zip) | |
console.log('title: ',title); | |
// Uniqify based on price+zip | |
var TAG=price+" - "+zip | |
// Uniqify based on price+zip+title | |
//var TAG=price+" - "+zip+" // "+title | |
if (tags.indexOf(TAG)>=0) { | |
console.log ('!!! IS DUPLICATED ON SAME PAGE'); | |
console.log ('fade 0.3 color #aaa'); | |
tmp.style.opacity="0.3"; | |
tmp.style.backgroundColor="#aaa"; | |
} | |
else if (localStorageTags.indexOf(TAG)>=0) { | |
console.log ('!!! IS DUPLICATE FROM GLOBAL DB'); | |
console.log ('fade 0.5 color #eee'); | |
tmp.style.opacity="0.5"; | |
tmp.style.backgroundColor="#eee"; | |
} | |
else { | |
tags.push(TAG); | |
localStorageTags.push(TAG); | |
} | |
}) | |
localStorage.tags=JSON.stringify(localStorageTags); | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment