-
-
Save raphaelrk/da99f0f06110374e36361e3c42e7e0f2 to your computer and use it in GitHub Desktop.
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
/// InstacartSponsoredItemsBlocker.js | |
console.log("InstacartSponsoredItemsBlocker started"); | |
document.addEventListener('DOMContentLoaded', (event) => { | |
// remove sponsored items | |
// setInterval(() => [...document.querySelectorAll('li')].map(elt => elt.innerText.includes('Sponsored') ? elt.style.display = 'none' : null), 500); | |
// make sponsored items have low opacity | |
setInterval(() => [...document.querySelectorAll('li')].map(elt => elt.innerText.includes('Sponsored') ? elt.style.opacity = '0.15' : null), 500); | |
// give "likely out of stock" items a pink background | |
setInterval(() => | |
[...document.querySelectorAll('li')].filter(elt => elt.innerText.includes('Request')).map(elt => { | |
elt.style.padding = '8px' | |
elt.style.backgroundColor = '#ff9999' | |
}), | |
500 | |
); | |
// sort by lowest price | |
const sortByLowestPrice = () => { | |
let lowestPriceInterval; | |
lowestPriceInterval = setInterval(() => { | |
let seeLowestFirst = document.querySelector(`li[id*='priceAsc']`); | |
if (seeLowestFirst) { | |
console.log("sorting by lowest price!"); | |
clearInterval(lowestPriceInterval); | |
seeLowestFirst.click(); | |
seeLowestFirst.click(); // click again to remove dropdown | |
} else { | |
// console.log("not yet sorting by lowest price"); | |
} | |
}, 500); | |
}; | |
sortByLowestPrice(); | |
// sort by lowest price any time url changes | |
let pathname = { current: window.location.pathname }; | |
setInterval(() => { | |
if (window.location.pathname !== pathname.current) { | |
pathname.current = window.location.pathname; | |
sortByLowestPrice(); | |
} | |
}, 500); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
uBlock Origin instructions:
1. Add to filters
instacart.com##+js(InstacartSponsoredItemsBlocker.js)
/// InstacartSponsoredItemsBlocker.js
which is where uBlock gets the filename from, with the file being the block of content below it, and I believe a blank line is considered to signal the end of the file which is why there are no blank lines)2. Add to userResourcesLocation
userResourcesLocation
to https://gist.githubusercontent.com/raphaelrk/da99f0f06110374e36361e3c42e7e0f2/raw/c61b8a8342dd0eb9b0a913c735461882929f44d2/CustomUBlockScripts.jsFor more information see Scriptlet injection. There's also a uBlock subreddit.