// ==UserScript== // @author Lex (10031) // @include http://vkontakte.ru/* // @include http://www.vkontakte.ru/* // ==/UserScript== // some ideas were borrowed from Malanin Pavel work // and stolen from somewhere in internet // it's Russia, people... function daysInMonth(m,y) { if (m==1) //feb if ((y%4 != 0) || (y%100 == 0 && y%400 != 0)) return 28 else return 29 else //other months return [31,0,31,30,31,30,31,31,30,31,30,31][m] } function addCalendar(){ //table header
//text='<table
style="font-size:10px"><tr><td>Пн</td><td>Вт</td><td>Ср</td><td>Чт</td><td>Пт</td><td>Сб</td><td>Вс</td></tr><tr>'
text='<table
style="font-size:10px"><tr><td>Вс</td><td>Пн</td><td>Вт</td><td>Ср</td><td>Чт</td><td>Пт</td><td>Сб</td></tr><tr>'
//get 1st date's day of week day=new Date() today=day.getDate() month=day.getMonth() year=day.getFullYear() day.setDate(1) day=day.getDay() //day=(day)?day-1:6 //fix to russian notation //fill the emptiness before for(col=0;col<day;col++) text+='<td> </td>' //col=day //fill the main structure last=daysInMonth(month,year) for(day=1;day<=last;day++){ style='' //if(col==5)style+='color:blue;' //if(col==6)style+='color:red;' if(col==0)style+='color:red;' if(col==3)style+='color:blue;' if(col==6)style+='color:blue;' if(day==today)style+='border:dotted thin;' text+='<td style="'+style+'">' text+=String(day) text+='</td>' if((col==6)&day!=last){ col=0 text+='</tr><tr>' } else col++ } //fill the emptiness after for(;col<6;col++) text+='<td> </td>' text+='</tr></table>' s=document.getElementById('sideBar') d=document.createElement('span') a=document.createElement('a') a.innerHTML=text a.href='http://vkontakte.ru/events.php?act=calendar' d.appendChild(a) s.appendChild(d) } document.addEventListener("DOMContentLoaded", addCalendar, false);
|