forked from meeeejin/srtmacro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
241 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (c) 2017 Mijin Ahn | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
# srtmacro | ||
# SRT Macro | ||
|
||
SRT Macro는 매진된 SRT 승차권 예매를 도와주는 크롬 확장 프로그램으로, 기존의 [Korail Macro](https://github.com/kswchoo/korailmacro)를 기반으로 만들어진 프로그램입니다. | ||
|
||
## 사용 방법 | ||
|
||
준비 중 | ||
|
||
## License | ||
|
||
MIT License |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<html> | ||
<script src="background.js"></script> | ||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function 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('assets/tada.mp3'); | ||
audio.play(); | ||
} | ||
|
||
chrome.extension.onMessage.addListener(function(message, sender, sendResponse) { | ||
if (message && message.type == 'playSound') { | ||
playSound(); | ||
sendResponse(true); | ||
} | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
function injectJs(srcFile) { | ||
var scr = document.createElement('script'); | ||
scr.src = srcFile; | ||
document.getElementsByTagName('head')[0].appendChild(scr); | ||
} | ||
|
||
var dsturl1 = "https://etk.srail.co.kr/hpg/hra/01/selectScheduleList.do?pageId=TK0101010000"; | ||
|
||
if (document.URL.substring(0, dsturl1.length) == dsturl1) { | ||
|
||
$(document).ready(function() { | ||
injectJs(chrome.extension.getURL('inject.js')); | ||
|
||
var coachSelected = JSON.parse(localStorage.getItem('coachSelected')); | ||
var firstSelected = JSON.parse(localStorage.getItem('firstSelected')); | ||
if (coachSelected == null) coachSelected = []; | ||
if (firstSelected == null) firstSelected = []; | ||
console.log("coach:" + coachSelected); | ||
console.log("first:" + firstSelected); | ||
|
||
if (localStorage.getItem('macro') == "true") { | ||
$("div.button").append('<a href="#" onclick="macrostop();" style="font-size:15px; margin-left:5px;"><img src="' + chrome.extension.getURL('images/btn_stop.png') + '"></a>'); | ||
|
||
} else { | ||
$("div.button").append('<a href="#" onclick="macro();" style="font-size:15px; margin-left:5px;"><img src="' + chrome.extension.getURL('images/btn_start.png') + '"></a>'); | ||
} | ||
|
||
// Inserts the macro button into the table. | ||
if ($("#search-list").length != 0) { | ||
var rows = $('#search-list table tr'); | ||
for (i = 1; i < rows.length; i++) { | ||
var columns = $(rows[i]).children('td'); | ||
var first = $(columns[5]); | ||
var coach = $(columns[6]); | ||
if (coach.children().length > 0) { | ||
coach.append($("<p class='p5'></p>")); | ||
var checkbox = $("<label></label>").html('<input type="checkbox" name="checkbox" class="coachMacro" value="' + i + '">매크로'); | ||
checkbox.children('input').prop('checked', coachSelected.indexOf(i+"") > -1); | ||
coach.append(checkbox); | ||
} | ||
if (first.children().length > 0) { | ||
first.append($("<p class='p5'></p>")); | ||
var checkbox = $("<label></label>").html('<input type="checkbox" name="checkbox" class="firstMacro" value="' + i + '">매크로'); | ||
checkbox.children('input').prop('checked', firstSelected.indexOf(i+"") > -1); | ||
first.append(checkbox); | ||
} | ||
} | ||
} | ||
|
||
if (localStorage.getItem('macro') == "true") { | ||
// Restores user preferences | ||
$("#psgInfoPerPrnb1").val(localStorage.getItem('psgInfoPerPrnb1')); | ||
$("#psgInfoPerPrnb5").val(localStorage.getItem('psgInfoPerPrnb5')); | ||
$("#psgInfoPerPrnb4").val(localStorage.getItem('psgInfoPerPrnb4')); | ||
$("#psgInfoPerPrnb2").val(localStorage.getItem('psgInfoPerPrnb2')); | ||
$("#psgInfoPerPrnb3").val(localStorage.getItem('psgInfoPerPrnb3')); | ||
$("#locSeatAttCd1").val(localStorage.getItem('locSeatAttCd1')); | ||
$("#rqSeatAttCd1").val(localStorage.getItem('rqSeatAttCd1')); | ||
|
||
if ($("#search-list").length != 0) { | ||
var rows = $('#search-list table tr'); | ||
|
||
var succeed = false; | ||
for (i = 1; i < rows.length; i++) { | ||
var columns = $(rows[i]).children('td'); | ||
|
||
var first = $(columns[5]); | ||
var coach = $(columns[6]); | ||
|
||
if (coachSelected.indexOf(i+"") > -1) { | ||
var coachSpecials = coach.children("a"); | ||
if (coachSpecials.length != 0) { | ||
for (j = 0; j < coachSpecials.length; j++) { | ||
name = $(coachSpecials[j]).attr('class'); | ||
if (name == 'button button-02') { | ||
$(coachSpecials[0])[0].click(); | ||
succeed = true; | ||
break; | ||
} | ||
} | ||
if (succeed == true) break; | ||
} | ||
} | ||
|
||
if (firstSelected.indexOf(i+"") > -1) { | ||
var firstSpecials = first.children("a"); | ||
if (firstSpecials.length != 0) { | ||
for (j = 0; j < firstSpecials.length; j++) { | ||
name = $(firstSpecials[j]).attr('class'); | ||
if (name == 'button button-02') { | ||
$(firstSpecials[0])[0].click(); | ||
succeed = true; | ||
break; | ||
} | ||
} | ||
if (succeed == true) break; | ||
} | ||
} | ||
} | ||
|
||
if (succeed == true) { | ||
localStorage.removeItem('macro'); | ||
localStorage.removeItem('coachSelected'); | ||
localStorage.removeItem('firstSelected'); | ||
localStorage.removeItem('psgInfoPerPrnb1'); | ||
localStorage.removeItem('psgInfoPerPrnb5'); | ||
localStorage.removeItem('psgInfoPerPrnb4'); | ||
localStorage.removeItem('psgInfoPerPrnb2'); | ||
localStorage.removeItem('psgInfoPerPrnb3'); | ||
localStorage.removeItem('locSeatAttCd1'); | ||
localStorage.removeItem('rqSeatAttCd1'); | ||
chrome.extension.sendMessage({type: 'playSound'}, function(data) { }); | ||
} else { | ||
setTimeout(function() { | ||
location.reload(); | ||
}, 1000); | ||
} | ||
} else { | ||
history.go(-1); | ||
} | ||
} | ||
}); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
window.showModalDialog = window.showModalDialog || function(url, arg, opt) { | ||
window.open(url, arg, opt); | ||
}; | ||
|
||
function macro() { | ||
coachSelected = [].map.call(document.querySelectorAll('.coachMacro:checked'), function (select) { | ||
return select.value; | ||
}); | ||
firstSelected = [].map.call(document.querySelectorAll('.firstMacro:checked'), function (select) { | ||
return select.value; | ||
}); | ||
|
||
if (coachSelected.length == 0 && firstSelected.length == 0) { | ||
alert("매크로를 실행하기 위해서는 예매하기 위한 열차 1개 이상을 선택하십시오."); | ||
} else { | ||
alert("매크로를 시작합니다.\n트럼펫 소리가 나면 바로 결제를 해주셔야 합니다."); | ||
|
||
localStorage.setItem('macro', true); | ||
localStorage.setItem('coachSelected', JSON.stringify(coachSelected)); | ||
localStorage.setItem('firstSelected', JSON.stringify(firstSelected)); | ||
|
||
// Stores user preferences. | ||
localStorage.setItem('psgInfoPerPrnb1', document.getElementsByName('psgInfoPerPrnb1')[0].value); | ||
localStorage.setItem('psgInfoPerPrnb5', document.getElementsByName('psgInfoPerPrnb5')[0].value); | ||
localStorage.setItem('psgInfoPerPrnb4', document.getElementsByName('psgInfoPerPrnb4')[0].value); | ||
localStorage.setItem('psgInfoPerPrnb2', document.getElementsByName('psgInfoPerPrnb2')[0].value); | ||
localStorage.setItem('psgInfoPerPrnb3', document.getElementsByName('psgInfoPerPrnb3')[0].value); | ||
localStorage.setItem('locSeatAttCd1', document.getElementsByName('locSeatAttCd1')[0].value); | ||
localStorage.setItem('rqSeatAttCd1', document.getElementsByName('rqSeatAttCd1')[0].value); | ||
|
||
location.reload(); | ||
} | ||
} | ||
|
||
function macrostop() { | ||
alert("매크로를 중지합니다.\n조건을 변경하여 재조회하신 후 다시 시작하실 수 있습니다."); | ||
|
||
localStorage.removeItem('macro'); | ||
localStorage.removeItem('coachSelected'); | ||
localStorage.removeItem('firstSelected'); | ||
localStorage.removeItem('psgInfoPerPrnb1'); | ||
localStorage.removeItem('psgInfoPerPrnb5'); | ||
localStorage.removeItem('psgInfoPerPrnb4'); | ||
localStorage.removeItem('psgInfoPerPrnb2'); | ||
localStorage.removeItem('psgInfoPerPrnb3'); | ||
localStorage.removeItem('locSeatAttCd1'); | ||
localStorage.removeItem('rqSeatAttCd1'); | ||
|
||
location.reload(); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "SRT Macro", | ||
"description": "SRT 자동 예약 매크로", | ||
"version": "1.0.0", | ||
"permissions": [ | ||
"https://etk.srail.co.kr/" | ||
], | ||
"icons": { | ||
"128": "images/icon128.png" | ||
}, | ||
"content_scripts": [ { | ||
"all_frames": true, | ||
"js": ["jquery-1.11.0.min.js", "content.js"], | ||
"matches": ["https://etk.srail.co.kr/*"], | ||
"run_at": "document_end" | ||
}], | ||
"background": { | ||
"page": "background.html" | ||
}, | ||
"web_accessible_resources": [ | ||
"inject.js", "images/btn_start.png", "images/btn_stop.png", "assets/tada.mp3" | ||
] | ||
} |