Created
February 13, 2013 03:36
-
-
Save maripo/4942053 to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name Rarejob Note Creator | |
// @namespace maripo.org | |
// @description Create evernote notes for RareJob lessons | |
// @include https://www.rarejob.com/login/top.php* | |
// @grant none | |
// @version 1 | |
// ==/UserScript== | |
(function () { | |
var MAIL_ADDRESS = '[email protected]'; | |
var NOTEBOOK_TAG = 'RareJob Lesson Notes'; | |
var REGEX_DATE = new RegExp('(\\d{4})/(\\d{1,2})/(\\d{1,2}).+?(午[前後])(\\d{1,2}):(\\d{1,2}).*'); | |
var parseCellContent = function (dateCell, tutorCell) { | |
var date = dateCell.textContent.replace(REGEX_DATE,'$1/$2/$3 $5:$6 $4').replace('午前','AM').replace('午後','PM'); | |
return {tutor:tutorCell.textContent, date: date}; | |
}; | |
var table = document.body.querySelector('div.mod table'); | |
var rows = table.getElementsByTagName('tr'); | |
for (var i=1; i<rows.length; i++) { | |
var cells = rows[i].childNodes; | |
if (cells.length!=3) continue; | |
var lesson = parseCellContent(cells[0], cells[1]); | |
var mailLink = document.createElement('a'); | |
mailLink.textContent = '+Evernote'; | |
mailLink.href = "mailto:" + MAIL_ADDRESS + "?subject=" + lesson.date + ' ' + lesson.tutor | |
+ ((NOTEBOOK_TAG)?"@" + NOTEBOOK_TAG:''); | |
cells[0].appendChild(mailLink); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment