// ==UserScript== // @name Add12306Calender // @namespace http://tampermonkey.net/ // @version 0.2 // @description 将Gmail收到的12306邮件加入日历项 // @author Formax // @match https://mail.google.com/* // @match https://gmail.com/* // @match https://www.gmail.com/* // @grant none // @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js // @downloadURL none // ==/UserScript== (function() { 'use strict'; jQuery(document).ready(function () { $(document).keydown(function(e){ if(e.which == 49 && e.ctrlKey && e.shiftKey){ var innerContent = $('.Bu')[0].innerHTML; var contt=new Object(); try{ contt = decripCR(innerContent,contt); var addUrl="https://www.google.com/calendar/render?action=TEMPLATE&text="+contt.title+"&dates="+contt.start+"/"+contt.end+"&details="+contt.remarkd+"&location="+contt.locat+"&sf=true&output=xml&ctz=Asia/Shanghai"; window.open(addUrl); } catch(e) { } } }); var decripCR = (function(innerHtm,calend){ var numMatch = innerHtm.match(/EC\d{8}/g); var infoMatch = innerHtm.match(/1\..{20,100}元/g); var infoContents =infoMatch[0].split(','); var timeContents =infoContents[1].split('日'); var mydate=new Date(); var newdate; if(timeContents[0].length>5){ newdate = new Date(timeContents[0].replace('年','-').replace('月','-')+" "+timeContents[1].split(':')[0]+":00"); } else{ var stdate=timeContents[0].split('月'); newdate= new Date(mydate.getFullYear(),stdate[0]-1,stdate[1],timeContents[1].split(':')[0]); } if(newdate