Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
448d4d0
ignore confirm in fn_chkPeople()
Aug 29, 2022
6899ab1
check all button
Aug 31, 2022
a58675e
adjust size of check-all-button
Aug 31, 2022
e3fb34e
prevent reloading while ticketing
Aug 31, 2022
79957fd
auto close popup
Aug 31, 2022
6398302
remove window.onload when closing popup
Aug 31, 2022
7fe6e5e
add ignoreConfirmPeople()
Aug 31, 2022
00bd3d3
add ignoreNonestopPopup() and fix ignoreDailyPopup()
Aug 31, 2022
f46741b
force reload when the page is freezed
tegrak Sep 1, 2022
bdad57b
add closeNonstopPopup()
tegrak Sep 2, 2022
89b4c3d
create content_header.js
tegrak Sep 2, 2022
49dfb76
store macro localStorage per tab
tegrak Sep 2, 2022
78069f8
reload.js: fix missing codes
tegrak Sep 2, 2022
4595eae
reload.js: remove unused param
tegrak Sep 2, 2022
e5558b0
content_header: use sessionStorage
tegrak Sep 2, 2022
e494461
Revert "content_header: use sessionStorage"
tegrak Sep 2, 2022
8a3e1e1
reload.js: remove unused code.
tegrak Sep 2, 2022
75693aa
manage macro tabs
tegrak Sep 2, 2022
245c4b4
header checkbox
tegrak Sep 5, 2022
100c149
fix indent
tegrak Sep 5, 2022
a2e45bd
clear reload timeout before execute macro()
tegrak Sep 5, 2022
4fe28a8
fix spelling
tegrak Sep 5, 2022
20ac0bd
header checkbox: set column to data attribute
tegrak Sep 5, 2022
1a08565
enable multi select mode with shift key
tegrak Sep 5, 2022
3d2fbe4
fix unnecessary character
tegrak Sep 7, 2022
082e7a4
start migrating Manifest V3
tegrak Oct 12, 2022
5edcc99
inject_nonstop_popup.js: auto close nonstop popup for Manifest V3
tegrak Oct 13, 2022
62cdb6b
add missing inject_nonstop_popup.js
tegrak Oct 14, 2022
ee7e15a
content.js: delete removing an element id in inject_click()
tegrak Oct 14, 2022
77b55a2
inject_click.js: check obj
tegrak Dec 28, 2022
a514cba
tabs to local strage
tegrak Dec 28, 2022
3ef52c4
enable windows events that blocked by korail
tegrak Jan 2, 2023
48d3ef9
content_header.js: make function addMacroTab() to const
tegrak Jan 2, 2023
803c590
background.js: make functions to const
tegrak Jan 2, 2023
8968b15
check array type of ktx-macro-tabs
tegrak Jan 2, 2023
f4d8d05
enable macro on family reservation
tegrak Jan 3, 2023
97169f1
reload.js: auto reloading on family reservation page
tegrak Jan 3, 2023
8a1725f
content.js: find the button with RESERVE_BUTTON
tegrak Jan 26, 2024
91e96dc
Merge pull request #1 from tegrak/devel
tegrak Mar 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 61 additions & 24 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,71 @@
const playSound = () => {
if (typeof (audio) != "undefined" && audio) {
audio.pause();
document.body.removeChild(audio);
audio = null;
}
audio = document.createElement('audio');
document.body.appendChild(audio);
audio.autoplay = true;
audio.src = chrome.extension.getURL('tada.mp3');
audio.play();
if (typeof (audio) != "undefined" && audio) {
audio.pause();
document.body.removeChild(audio);
audio = null;
}
audio = document.createElement('audio');
document.body.appendChild(audio);
audio.autoplay = true;
audio.src = chrome.runtime.getURL('tada.mp3');
audio.play();
};

const sendTelegramMessage = () => {
const botToken = localStorage.getItem('KTX_MACRO::bot-token');
const chatId = localStorage.getItem('KTX_MACRO::chat-id');
chrome.storage.local.get(
['ktx-macro-bot-token', 'ktx-macro-chat-id'],
function (result) {
const msg = encodeURI('예약을 시도하였습니다. 예약을 확인해주세요.');
const url = `https://api.telegram.org/bot${result['ktx-macro-bot-token']}/sendmessage?chat_id=${result['ktx-macro-chat-id']}&text=${msg}`;

if (!botToken || !chatId) {
return;
}
fetch(url);
}
);
}

const msg = encodeURI('예약을 시도하였습니다. 예약을 확인해주세요.');
const url = `https://api.telegram.org/bot${botToken}/sendmessage?chat_id=${chatId}&text=${msg}`;
const removeMacroTab = (tabid) => {
chrome.storage.local.get(["ktx-macro-tabs"],
function (result) {
let tabs = result["ktx-macro-tabs"];
console.log('remove tab tabs: ' + tabs + ', tabid: ' + tabid);
if (typeof(tabs) != "object" || !Array.isArray(tabs))
tabs = [];

fetch(url);
var index = tabs.indexOf(tabid);
if (index != -1) {
tabs.splice(index, 1);
chrome.storage.local.set({"ktx-macro-tabs": tabs});
}
}
);
}

chrome.extension.onMessage.addListener((message, sender, sendResponse) => {
if (message && message.type == 'successTicketing') {
playSound();
sendTelegramMessage();
sendResponse(true);
}
const checkMacroTabs = () => {
var tabid;
for (tabid of tabs) {
chrome.tabs.get(tabid, function (tab) {
if (chrome.runtime.lastError) {
console.log(chrome.runtime.lastError);
}
if (!tab) {
removeTab(tabid);
}
});
}
};

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
//console.log('message: ' + message);
if (message && message.type == 'successTicketing') {
//playSound();
sendTelegramMessage();
sendResponse(true);
}
else if (message && message.type == 'tabId') {
sendResponse(sender.tab.id);
}
});

chrome.tabs.onRemoved.addListener(function (tabid, removed) {
removeMacroTab(tabid);
});
37 changes: 26 additions & 11 deletions content.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
.ktx-macro-button {
width: 175px;
height: 38px;
line-height: 38px;
text-align: center;
background: #f46b45;
background: -webkit-linear-gradient(to bottom, #eea849, #f46b45);
background: linear-gradient(to bottom, #eea849, #f46b45);
color: #ffffff;
font-size: 13px;
border: 1px solid #f76707;
cursor: pointer;
width: 175px;
height: 38px;
line-height: 38px;
text-align: center;
background: #f46b45;
background: -webkit-linear-gradient(to bottom, #eea849, #f46b45);
background: linear-gradient(to bottom, #eea849, #f46b45);
color: #ffffff;
font-size: 13px;
border: 1px solid #f76707;
cursor: pointer;
}

.check-all-button {
padding-left: 10px;
padding-right: 10px;
height: 38px;
line-height: 38px;
text-align: center;
background: #f46b45;
background: -webkit-linear-gradient(to bottom, #eea849, #f46b45);
background: linear-gradient(to bottom, #eea849, #f46b45);
color: #ffffff;
font-size: 13px;
border: 1px solid #f76707;
cursor: pointer;
}
Loading