Created
April 15, 2015 09:03
-
-
Save cieux1/9d346c4d278da6e87bb4 to your computer and use it in GitHub Desktop.
how I click my time card via my pebble
This file contains hidden or 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
| require 'gmail' | |
| require 'chatwork' | |
| require './click_timecard.rb' | |
| ChatWork.api_key = "CHATWORKのAPIキー" | |
| def chat(text) | |
| ChatWork::Message.create( room_id: "xxxxxxx", body: text ) | |
| end | |
| begin | |
| gmail = Gmail.connect("メアド@gmail.com", "パスワード") | |
| puts "login OK." if gmail.logged_in? | |
| t = Time.now | |
| nine = Time.new(t.year, t.month, t.day, "+9") | |
| nine_thirtyone = nine + 1900 | |
| 100.times do | |
| if Time.now.between?(nine, nine_thirtyone) | |
| if gmail.inbox.count(:on => Date.today, :subject => "出勤したよing!!!") > 0 | |
| shukkin = true | |
| stamp_time_card | |
| chat("(F)") | |
| else | |
| puts Time.now | |
| end | |
| end | |
| break if shukkin | |
| sleep 20 | |
| end | |
| rescue => e | |
| puts(e) | |
| ensure | |
| gmail.logout | |
| end |
This file contains hidden or 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
| require "mechanize" | |
| def stamp_time_card(mode="s_go") | |
| agent = Mechanize.new | |
| agent.user_agent_alias = 'Mac FireFox' | |
| # select your section | |
| page = agent.get("ログインURL") | |
| form = page.form("form2") | |
| form.field_with(:name => "lgid").option_with(:value => "XX").click | |
| # load uid options and submit | |
| uid_page = form.submit( form.button_with(:name => "s_change") ) | |
| uid_form = uid_page.form("form2") | |
| uid_form.field_with(:name => "uid").option_with(:value => "XX").click | |
| uid_form.field_with(:name => "_word").value = "XXXXXXXXXX" | |
| agent.submit(uid_form) | |
| # move to timecard url and click btn | |
| time_card_page = agent.get("つぎのページのURL") | |
| time_card_form = time_card_page.form("_form") | |
| # taikin or shukkin | |
| if mode == "s_leave" | |
| puts "Are you sure you taikin?" | |
| puts "[Y/n]" | |
| if gets.chomp == "Y" | |
| time_card_form.submit( time_card_form.button_with(:name => mode) ) | |
| else | |
| puts "so bad... keep working!" | |
| end | |
| else | |
| time_card_form.submit( time_card_form.button_with(:name => mode) ) | |
| end | |
| end |
This file contains hidden or 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
| # https://cloudpebble.net/ | |
| simply.on('singleClick', function(e) { | |
| // console.log(util2.format('single clicked $button!', e)); | |
| if (e.button == "select"){ | |
| ajax({ url: 'アクセスするとメールが送られるappのURL' }, function(){ | |
| simply.text({ body: 'Mail sent!' }); | |
| }); | |
| } | |
| }); | |
| simply.setText({ | |
| title: 'My SHUKKIN App', | |
| body: 'PRESS SELECT for Shukkin', | |
| }, true); |
This file contains hidden or 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
| on run {input, parameters} | |
| tell application "Terminal" | |
| activate | |
| do script "cd /Users/rubyスクリプトまでのパス/time_card && ruby check_the_shukkin_mail.rb && exit" | |
| end tell | |
| return input | |
| end run | |
| # this will launch at 9 am on every weekdays. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment