Skip to content

Instantly share code, notes, and snippets.

const config = { childList: true, subtree: true };
const $target = document.querySelector('body');
const removeAds = () => {
[...document.querySelectorAll('[href="#"]')]
.filter(e => e.innerText === 'Sponsored')
.forEach(e => {
var parent = e.closest('[id^="substream_"]');
console.log('Another ad bites the dust!');
parent.parentElement.removeChild(parent);
});
const config = { childList: true, subtree: true };
const $target = document.querySelector('body');
const removeAds = () => {
const selector = '[data-testid="placementTracking"]';
document.querySelectorAll(selector).forEach(e => {
console.log('Another ad bites the dust!');
e.parentElement.removeChild(e);
});
};
removeAds();

Keybase proof

I hereby claim:

  • I am jeffwesson on github.
  • I am jeffwesson (https://keybase.io/jeffwesson) on keybase.
  • I have a public key ASDKTllWxBegNZqvgbMit1xzixOrXwY-6_h6lYn4Om6KbAo

To claim this, I am signing this object:

@jeffwesson
jeffwesson / buy-buy-baby-total.js
Created August 9, 2017 04:35
Sums items in a baby registry on Buy Buy Baby
Array.prototype.slice.call(document.querySelectorAll('.productRow .productContainer .productContent')).reduce((a, item) => {
let o = {};
o['requested'] = parseInt(item.querySelector('.requested').innerText.replace(/\D/g, ''));
o['purchased'] = parseInt(item.querySelector('.purchase').innerText.replace(/\D/g, ''));
o['price'] = parseFloat((item.querySelector('.rlpPrice') || item.querySelector('.toalpriceLtl')).innerText.replace(/[^\d\.]/g, ''));
a.push(o);
return a;
}, []).filter(item => item.requested !== item.purchased).reduce((s, item) => {
s += item.price * item.requested - item.purchased;
return s;
@jeffwesson
jeffwesson / format-ssn.html
Created April 26, 2016 05:39
ssn formatter
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<input type="text" id="x" maxlength="11" pattern="\d{3}\-\d{2}\-\d{4}">
<script>
@jeffwesson
jeffwesson / bubbleSort.js
Last active April 1, 2016 06:39
BubbleSort Algorithm
const bubbleSort = function (arr) {
let store = null;
let maxProfit = 0;
for (let i = 0; i < arr.length; i++) {
for (let j = 0; j < arr.length - 1; j++) {
if (arr[j] > arr[j + 1]) {
store = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = store;
}
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
function reverseString(str) {
var chars = str.split(""),
letterNum = 1,
start = "A".charCodeAt(0),
end = "Z".charCodeAt(0),
list = [];
function opposite(char) {
var oppCharCode,
re = /[A-Za-z]/g;
@jeffwesson
jeffwesson / getWishlistTotal.js
Created August 4, 2015 06:38
WIP: Get subtotal for all items in a given amazon wishlist
var divs = document.getElementsByTagName("div");
var products = [];
for (var i = 0; i < divs.length; i ++) {
if (/^item_price_/.test(divs[i].id)) {
products.push(divs[i]);
}
}
var rawPrices = [];
var priceClass = /-price\b/;
@jeffwesson
jeffwesson / formatNumber
Last active August 29, 2015 14:20
Format a given number with thousands delimited by commas
function formatNumber(num) {
if (!isNaN(Number(num))) {
var numLength = num.toString().split('').length;
if (numLength % 3 !== 0) {
// do complex shit,
// but return 0 for now
return 0;
}
var regexString = '';
var formatTemplate = '';