-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathticket-info.min.js
1 lines (1 loc) · 2.1 KB
/
ticket-info.min.js
1
(()=>{!function(){!function(){if(-1==location.href.indexOf("eventbrite")){const e="You must go to the Eventbrite event page and run the script from there!";throw console.error(e),new Error(e)}}();let e=null;const t=require("mediatorjs"),n=t&&t.get("ticketOrderOptions");if(n){const t=function(e){const t=e.match(/\"inventoryLevel\":[0-9]+/g);return t?t.map(e=>e.replace(/"inventoryLevel":/,"")):[]}(document.documentElement.innerHTML);t.length==n.collection.length&&n.collection.forEach((e,n)=>{e.number_of_tickets_remaining=e.number_of_tickets_remaining||t[n]});const o=function(e){return e.collection.map(function(e){return{name:e.ticket_name,quantity:{quantity_remaining:e.number_of_tickets_remaining},cost:e.is_free?"Free":null==e.total_cost?e.ticket_price:e.total_cost.display,status:{status_is_sold_out:e.status_is_sold_out,status_is_ended:e.status_is_ended,status_not_yet_started:e.not_yet_started,on_sale_status:e.on_sale_status},dates:{sales_start:e.start_sales_with_tz?new Date(e.start_sales_with_tz.utc).toLocaleString():"unavailable",sales_end:e.end_sales_with_tz?new Date(e.end_sales_with_tz.utc).toLocaleString():"unavailable"}}})}(n);e=JSON.stringify(o,null,2),o.length>1&&(e="<strong>There are several ticket classes...</strong>\n\n"+e)}else e="Unable to retrieve ticket information. Eventbrite must have changed their code...";console.log(e),function(e){const t="tooltip-custom-event-info";let n=document.getElementById(t);null!=n&&document.body.removeChild(n),(n=document.createElement("div")).id=t,n.style.cssText="width: 40%; max-height: 75%; white-space: pre; overflow-y: auto; background-color: #333; color: #EEE; border-radius: 6px; box-shadow: 0px 0px 5px #999; position: fixed; left: 1em; top: 6em; z-index: 10001; padding: 1em 2em 1em 1em;";const o=document.createElement("a");o.innerHTML="×",o.href="javascript:void(0)",o.onclick=function(){document.body.removeChild(this.parentElement)},o.style="float: right; font-weight: bold; font-size: 2.5em; line-height: 1em;position: fixed; left: 40%";const i=document.createElement("div");i.innerHTML=e,n.appendChild(o),n.appendChild(i),document.body.appendChild(n)}(e)}()})();