Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

ignore confirm in fn_chkPeople() #10

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 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
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
87 changes: 63 additions & 24 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,73 @@
let tabs = [];

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}`;
function addTab(tabid) {
if (tabs.indexOf(tabid) === -1)
tabs.push(tabid);
}

fetch(url);
function removeTab(tabid) {
console.log('remove tab tabs: ' + tabs + ', tabid: ' + tabid);
var index = tabs.indexOf(tabid);
if (index != -1)
tabs.splice(index, 1);
}

chrome.extension.onMessage.addListener((message, sender, sendResponse) => {
if (message && message.type == 'successTicketing') {
playSound();
sendTelegramMessage();
sendResponse(true);
}
function checkTabs() {
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') {
addTab(sender.tab.id);
sendResponse(sender.tab.id);
}
else if (message && message.type == 'tabs') {
checkTabs();
sendResponse(tabs);
}
});

chrome.tabs.onRemoved.addListener(function (tabid, removed) {
removeTab(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