Last active
February 14, 2019 15:44
-
-
Save trinonsense/70e78ecbd5b2a684987986155388e1cd 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
// to be used with: https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija?hl=en | |
// thank you: http://youmightnotneedjquery.com/ | |
onPageLoad(buyTickets(4, 'https://www.ticketfly.com/purchase/event/1828188')); | |
function buyTickets(amount, ticketHref) { | |
if (location.href !== ticketHref) return; | |
const buySubmitEl = document.querySelectorAll('#bestSeats') | |
if (buySubmitEl.length) { | |
const clickEvent = document.createEvent('HTMLEvents'); | |
clickEvent.initEvent('click', true, false); | |
const addEl = document.querySelectorAll('.plus')[0] | |
Array(amount).fill(amount).forEach(() => addEl.dispatchEvent(clickEvent)) | |
buySubmitEl[0].dispatchEvent(clickEvent) | |
} else { | |
location.reload(); | |
} | |
} | |
function onPageLoad(fn) { | |
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){ | |
fn(); | |
} else { | |
document.addEventListener('DOMContentLoaded', fn); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment