Here is the code of my first, and probably totally useless for anybody else, firefox extension!
I have crafted it as a little experiment with chikenfoot. Chickenfoot is nice, it’s similar to greasemonkey but easier to use. And it can wrap up your scripts as firefox extensions for you.
So, coming to cotw, its purpose is to automathically open up in a new tab the last episode of composer of the week for me when I visit the page. “Composer of the week” is broadcasted from 12.00 to 13.00 from monday to friday, english time. So, as I live in Italy (one hour ahead), I just test the hour of the day and if it’s before 14.30 then I open up yesterday’s episode; otherwise I open up a tab with today’s episode. That’s is! If you combine that with a proper “quick search” mapping for the program’s homepage, say “cotw”, you can juste type “cotw” in firefox’s address bar and enjoy the music.
Here’s the code:
1 // ==UserScript== 2 // @extensionName cotw 3 // @extensionAuthor Stefano Negri 4 // @extensionDescription listen to the last episode of BBC3's Composer of the week 5 // @extensionGUID 8d1f5e3d-2f2c-2aaf-0949-67963d35b50a 6 // @version 0.1 7 // @name cotw_last_episode 8 // @when Pages Match 9 // @includes http://www.bbc.co.uk/radio3/cotw/ 10 // ==/UserScript== 11 12 13 var today = new Date(); 14 var day = today.getDay(); 15 var last; 16 17 if ((today.getHours() > 14) || ((today.getHours() = 14) && (today.getMinutes() > 30))) { 18 last = day; 19 } else { 20 switch (day) { 21 case 1: last = 5; break; 22 case 2: last = 1; break; 23 case 3: last = 2; break; 24 case 4: last = 3; break; 25 case 5: last = 4; break; 21 case 6: last = 5; break; 21 case 7: last = 5; break; 26 } 27 } 28 29 var lastDayName; 30 31 switch (last) { 32 case 1: lastDayName = 'Monday'; break; 33 case 2: lastDayName = 'Tuesday'; break; 34 case 3: lastDayName = 'Wednesday'; break; 35 case 4: lastDayName = 'Thursday'; break; 36 case 5: lastDayName = 'Friday'; break; 37 } 38 39 link = find(lastDayName).element 40 openTab(link)
You can download this extension from here, but to install you have to rename it from odt to xpi.
Postato in: Uncategorized

