Last active
June 12, 2023 11:07
-
-
Save scriptify/bce9b1d88d64ae11931cdda26f65c3e1 to your computer and use it in GitHub Desktop.
Be the first to know
This file contains hidden or 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
function executeAlarm() { | |
// Create new audio context | |
var audioContext = new (window.AudioContext || window.webkitAudioContext)(); | |
// Create OscillatorNode to represent the tone | |
var oscillator = audioContext.createOscillator(); | |
// Define the type of wave the oscillator will output | |
oscillator.type = 'square'; | |
// Define the frequency of the oscillator in hertz | |
oscillator.frequency.value = 440; | |
// Connect the oscillator to the audio context's destination (the speakers) | |
oscillator.connect(audioContext.destination); | |
// Start the oscillator now | |
oscillator.start(); | |
// Stop the oscillator after 1 second | |
setTimeout(function(){ | |
oscillator.stop(); | |
}, 10000); | |
document.title = 'ALERT !!!!' | |
} | |
async function fetchTours() { | |
const WISHED_DATE = '2023-07-04'; | |
const token = | |
'YOUR_JWT'; | |
const tours = await fetch(`https://bassliner.org/api/event/tours`, { | |
method: 'POST', | |
headers: { | |
Authorization: `Bearer ${token}`, | |
'Content-Type': 'application/json', | |
}, | |
body: JSON.stringify({ | |
event_id: 110, | |
tour_type_id: 2, | |
meeting_point_id: 1, | |
}), | |
}).then((res) => res.json()); | |
const foundTour = tours | |
.filter((tour) => tour.time.includes(WISHED_DATE)) | |
.find((tour) => tour.departures.find((dep) => dep.price_groups.length > 0)); | |
if (foundTour) { | |
executeAlarm() | |
return true; | |
} | |
return false; | |
} | |
function searchTours() { | |
const interval = setInterval(async () => { | |
const found = await fetchTours(); | |
if (found) { | |
clearInterval(interval); | |
} | |
}, 1000 * 30); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment