forked from mrbigmouth/kktixRobot
-
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
0 parents
commit 04e44d8
Showing
15 changed files
with
9,872 additions
and
0 deletions.
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,22 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
*.sln merge=union | ||
*.csproj merge=union | ||
*.vbproj merge=union | ||
*.fsproj merge=union | ||
*.dbproj merge=union | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
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,215 @@ | ||
################# | ||
## Eclipse | ||
################# | ||
|
||
*.pydevproject | ||
.project | ||
.metadata | ||
bin/ | ||
tmp/ | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.classpath | ||
.settings/ | ||
.loadpath | ||
|
||
# External tool builders | ||
.externalToolBuilders/ | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# CDT-specific | ||
.cproject | ||
|
||
# PDT-specific | ||
.buildpath | ||
|
||
|
||
################# | ||
## Visual Studio | ||
################# | ||
|
||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ons. | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.sln.docstates | ||
|
||
# Build results | ||
|
||
[Dd]ebug/ | ||
[Rr]elease/ | ||
x64/ | ||
build/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
|
||
# MSTest test Results | ||
[Tt]est[Rr]esult*/ | ||
[Bb]uild[Ll]og.* | ||
|
||
*_i.c | ||
*_p.c | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.rsp | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.tmp_proj | ||
*.log | ||
*.vspscc | ||
*.vssscc | ||
.builds | ||
*.pidb | ||
*.log | ||
*.scc | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
*.cachefile | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
*.vspx | ||
|
||
# Guidance Automation Toolkit | ||
*.gpState | ||
|
||
# ReSharper is a .NET coding add-in | ||
_ReSharper*/ | ||
*.[Rr]e[Ss]harper | ||
|
||
# TeamCity is a build add-in | ||
_TeamCity* | ||
|
||
# DotCover is a Code Coverage Tool | ||
*.dotCover | ||
|
||
# NCrunch | ||
*.ncrunch* | ||
.*crunch*.local.xml | ||
|
||
# Installshield output folder | ||
[Ee]xpress/ | ||
|
||
# DocProject is a documentation generator add-in | ||
DocProject/buildhelp/ | ||
DocProject/Help/*.HxT | ||
DocProject/Help/*.HxC | ||
DocProject/Help/*.hhc | ||
DocProject/Help/*.hhk | ||
DocProject/Help/*.hhp | ||
DocProject/Help/Html2 | ||
DocProject/Help/html | ||
|
||
# Click-Once directory | ||
publish/ | ||
|
||
# Publish Web Output | ||
*.Publish.xml | ||
*.pubxml | ||
|
||
# NuGet Packages Directory | ||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line | ||
#packages/ | ||
|
||
# Windows Azure Build Output | ||
csx | ||
*.build.csdef | ||
|
||
# Windows Store app package directory | ||
AppPackages/ | ||
|
||
# Others | ||
sql/ | ||
*.Cache | ||
ClientBin/ | ||
[Ss]tyle[Cc]op.* | ||
~$* | ||
*~ | ||
*.dbmdl | ||
*.[Pp]ublish.xml | ||
*.pfx | ||
*.publishsettings | ||
|
||
# RIA/Silverlight projects | ||
Generated_Code/ | ||
|
||
# Backup & report files from converting an old project file to a newer | ||
# Visual Studio version. Backup files are not needed, because we have git ;-) | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
UpgradeLog*.htm | ||
|
||
# SQL Server files | ||
App_Data/*.mdf | ||
App_Data/*.ldf | ||
|
||
############# | ||
## Windows detritus | ||
############# | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
ehthumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Mac crap | ||
.DS_Store | ||
|
||
|
||
############# | ||
## Python | ||
############# | ||
|
||
*.py[co] | ||
|
||
# Packages | ||
*.egg | ||
*.egg-info | ||
dist/ | ||
build/ | ||
eggs/ | ||
parts/ | ||
var/ | ||
sdist/ | ||
develop-eggs/ | ||
.installed.cfg | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
|
||
#Translations | ||
*.mo | ||
|
||
#Mr Developer | ||
.mr.developer.cfg |
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 @@ | ||
|
||
使用方法: | ||
以google chrome瀏覽器安裝插件, | ||
進入kktix的活動頁面後,網址列右方即有按鈕出現, | ||
點擊後即可設定並啟動購票機器人。 | ||
|
||
目前為初版,肯定有很多不足之處,需要更多的測試。 |
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,72 @@ | ||
var Robot = {}; | ||
var $Audio = {}; | ||
|
||
//接受訊息時 | ||
chrome.runtime.onMessage.addListener( | ||
function(msg, sender, respond) { | ||
var tabId = sender.tab ? sender.tab.id : msg.tab | ||
, robot | ||
; | ||
|
||
//顯示機器人設定button | ||
chrome.pageAction.show(tabId); | ||
|
||
//若該tab尚未創建機器人資訊,則創建 | ||
if (Robot[ tabId ] === undefined) { | ||
Robot[ tabId ] = {'status' : 'unprepared'}; | ||
} | ||
|
||
//內部用快捷變數 | ||
robot = Robot[ tabId ]; | ||
//根據msg type執行程式/回傳結果 | ||
switch (msg.type) { | ||
//獲取票種資訊 | ||
case 'ticketInfo': | ||
//更新/插入資訊 | ||
robot.title = msg.title; | ||
robot.tickets = msg.tickets; | ||
robot.status = 'prepared'; | ||
respond(true); | ||
break; | ||
|
||
//取得機器人資訊 | ||
case 'getRobot' : | ||
respond(robot); | ||
break; | ||
|
||
//撥放音效 | ||
case 'playAudio' : | ||
var $audio = $($.parseHTML('<audio' + (robot.audioLoop ? ' loop' : '') + '><source src="' + robot.audio + '"></audio>')); | ||
$audio[0].play(); | ||
if ($Audio[ tabId ]) { | ||
$Audio[ tabId ][0].pause(); | ||
delete $Audio[ tabId ]; | ||
} | ||
$Audio[ tabId ] = $audio; | ||
respond(true); | ||
break; | ||
|
||
//停止機器人 | ||
case 'stopRobot' : | ||
if ($Audio[ tabId ]) { | ||
$Audio[ tabId ][0].pause(); | ||
robot.status = 'prepared'; | ||
delete $Audio[ tabId ]; | ||
respond(true); | ||
} | ||
break; | ||
} | ||
} | ||
); | ||
|
||
//關閉tab時 | ||
chrome.tabs.onRemoved.addListener(function(tabId) { | ||
var robot = Robot[ tabId ]; | ||
if (robot !== undefined) { | ||
if ($Audio[ tabId ]) { | ||
$Audio[ tabId ][0].pause(); | ||
delete $Audio[ tabId ]; | ||
} | ||
delete Robot[ tabId ]; | ||
} | ||
}); |
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,52 @@ | ||
//取得目前tab的機器人資訊 | ||
chrome.runtime.sendMessage( | ||
{'type' : 'getRobot'} | ||
, function(robot) { | ||
switch (robot.status) { | ||
//機器人尚未設置 | ||
case 'unprepared' : | ||
//獲取票種資訊 | ||
var tickets = []; | ||
$('div.tickets table tbody tr').each(function() { | ||
var $this = $(this) | ||
, data = {} | ||
, period | ||
; | ||
|
||
data.name = $this.find('td.name').text().replace(/^\s+|\s+$/gm,''); | ||
period = $this.find('td.period').text().match(/(\d+\/\d+\/\d+ \d+\:\d+)/g); | ||
if (period.length > 1) { | ||
data.start = Date.parse(period[0]); | ||
data.end = Date.parse(period[1]); | ||
} | ||
else { | ||
data.end = Date.parse(period[0]); | ||
} | ||
|
||
tickets.push(data); | ||
}); | ||
|
||
//插入/更新票種資訊 | ||
chrome.runtime.sendMessage( | ||
{'type' : 'ticketInfo' | ||
,'title' : $('div.header-title').text().replace(/^\s+|\s+$/gm,'') | ||
,'tickets' : tickets | ||
} | ||
); | ||
break; | ||
|
||
|
||
//機器人行動中 | ||
case 'processing' : | ||
//分析url | ||
var url = location.href.match(/.kktix.cc\/events\/([a-zA-Z0-9_\-]+)/); | ||
if (url) { | ||
url = url[1]; | ||
url = 'https://kktix.com/events/' + url + '/registrations/new'; | ||
//進入售票頁面 | ||
location.href = url; | ||
} | ||
break; | ||
} | ||
} | ||
); |
Oops, something went wrong.