// ==UserScript== // @author Lex (10031) // @include http://vkontakte.ru/* // @include http://www.vkontakte.ru/* // ==/UserScript== // parts of script were borrowed from Malanin Pavel work // and stolen from somewhere in internet // it's Russia, people... function utf(s) { function getByte(s,i) { return s.charCodeAt(i)&255; } var r=''; var i=0,n=0; while(i<s.length) { n=getByte(s,i);
if ((n&252)==252)
n=((n&1)<<30)+((getByte(s,++i)&63)<<24)+((getByte(s,++i)&63)<<18)+((getByte(s,++i)&63)<<12)+((getByte(s,++i)&63)<<6)+(getByte(s,++i)&63)
else if ((n&248)==248)
n=((n&3)<<24)+((getByte(s,++i)&63)<<18)+((getByte(s,++i)&63)<<12)+((getByte(s,++i)&63)<<6)+(getByte(s,++i)&63)
else if ((n&240)==240)
n=((n&7)<<18)+((getByte(s,++i)&63)<<12)+((getByte(s,++i)&63)<<6)+(getByte(s,++i)&63)
else if ((n&224)==224) n=((n&15)<<12)+((getByte(s,++i)&63)<<6)+(getByte(s,++i)&63) else if ((n&192)==192) n=((n&63)<<6)+(getByte(s,++i)&63); r+=String.fromCharCode(n); i++; } return r; } 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=utf('<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(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);
|