Skip to content

Instantly share code, notes, and snippets.

@morgan9e
Last active November 4, 2023 15:24
Show Gist options
  • Save morgan9e/410dc829b7afa30366e96844c3f3f1a1 to your computer and use it in GitHub Desktop.
Save morgan9e/410dc829b7afa30366e96844c3f3f1a1 to your computer and use it in GitHub Desktop.
sr_macro.userscript
// ==UserScript==
// @name SR Macro
// @version 1
// @description SR Macro
// @author https://github.com/morgan9e
// @match https://etk.srail.kr/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=srail.kr
// ==/UserScript==
(function() {
if (window.location.href.includes("confirmReservationInfo.do")) {
let seatInfo = document.querySelector(".mgl20")?.innerText;
if (seatInfo === "잔여석없음") {
setTimeout(() => history.back(), 600);
} else if (document.getElementById("list-form")) {
const url = "https://example.com/sendapi";
const data = {
pn: "01012345678",
content: "Conplete"
};
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch((error) => {
console.error('Error:', error);
});
}
}
else if (window.location.href.includes("selectScheduleList.do")) {
var idx = 0;
// 1 First 0 Normal
var grade = 1;
console.log(document.getElementsByClassName("trnNo")[idx].innerText);
let resultForm = document.getElementById('result-form');
if (resultForm) {
requestReservationInfo(resultForm, idx, grade+1, '1101', true, true, '');
} else {
let searchForm = document.getElementById("search-form");
if (searchForm) {
searchForm.submit();
}
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment