Skip to content

Instantly share code, notes, and snippets.

@trinonsense
Last active February 14, 2019 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trinonsense/70e78ecbd5b2a684987986155388e1cd to your computer and use it in GitHub Desktop.
Save trinonsense/70e78ecbd5b2a684987986155388e1cd to your computer and use it in GitHub Desktop.
// 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