diff options
| author | anekos | 2013-09-25 20:13:16 +0900 | 
|---|---|---|
| committer | anekos | 2013-09-25 20:13:16 +0900 | 
| commit | 96fa68a3a9d56e697a8d8e765a327aefc6f6eff0 (patch) | |
| tree | a9c16e64d9ae885b379a5df114e9779f831cdbda | |
| parent | 4526f7ec3099b07f343d463b9a495f4e91c653ac (diff) | |
| download | vimperator-plugins-96fa68a3a9d56e697a8d8e765a327aefc6f6eff0.tar.bz2 | |
Pebble notification
| -rw-r--r-- | twittperator/pebble.tw | 37 | 
1 files changed, 37 insertions, 0 deletions
| diff --git a/twittperator/pebble.tw b/twittperator/pebble.tw new file mode 100644 index 0000000..1feb454 --- /dev/null +++ b/twittperator/pebble.tw @@ -0,0 +1,37 @@ +/* + * Please write the below line into .vimperatorrc. + * let g:twittperator_plugin_pebble = 1 + * let g:twittperator_plugin_pebble_user_id = '<USER_ID>'; + * let g:twittperator_plugin_pebble_user_token = '<USER_TOKEN>'; + * let g:twittperator_screen_name = "<YOUR_SCREEN_NAME>" + */ + +(function () { +  let screenName = liberator.globalVariables.twittperator_screen_name; +  let userId = liberator.globalVariables.twittperator_plugin_pebble_user_id; +  let userToken = liberator.globalVariables.twittperator_plugin_pebble_user_token; + +  function notify (username) { +    let body = [ +      'userId=' + userId, +      'userToken=' + userToken, +      'title=Twitter', +      'body=' + encodeURIComponent('reply from ' + username), +      'type=notification'].join('&'); + +    let xhr = new XMLHttpRequest(); +    xhr.open('POST', 'https://ofkorth.net/pebble/send', true, null, null); +    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + +    xhr.send(body); +  } + +  plugins.twittperator.ChirpUserStream.addListener( +    function onMsg (msg, raw) { +      if (msg.text && msg.user && msg.in_reply_to_screen_name === screenName) +        notify(msg.user.screen_name, msg.text); +    } +  ); +})(); + +// vim: sw=2 ts=2 et fdm=marker ft=javascript: | 
