/    Sign up×
Community /Pin to ProfileBookmark

Custom Firefox tab

Hi, all:

I’m trying to create a custom Firefox tab that will open up a specific search result in Google. I look for my TV shows on tv.com, and I do so by using this search:

site:[url]www.tv.com[/url] “Airs: Sunday September 21, 2008”

If you google that search, you’ll see what I mean. But I have to fix the date each time I run the search, and I want to automate it so I can simply set it as a bookmark/tab to open.

Firefox will run javascript as a search; check this out:

javascript:location.href=’http://www.google.com/search?hl=en&q=’+’site:www.tv.com%20’+'”Airs%20’+new%20Date().toLocaleString(“%A,%20%B,%20%m,%20%Y“)+'”‘

It searches for this: site:[url]www.tv.com[/url] “Airs Sun 21 Sep 2008 10:28:18 PM EDT”

Is there a way to alter that Javascript snippet to get it to adhere to this format exactly, and update the date automatically? I lack the JS-fu to figure it out.

site:[url]www.tv.com[/url] “Airs: Sunday September 21, 2008”?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@speghettiCodeSep 22.2008 — If I understand your question correctly, why not use an array for your days and months and something like:
[CODE]var today = days[thisDate.getDay()];[/CODE]
to access them. Then just use those variables to create the query you need.
Copy linkTweet thisAlerts:
@tarahmarieauthorSep 22.2008 — I speak Java, not Javascript, but I think I understand what you're saying. Were I to create an array in Java for instance, is it possible for Javascript to access it?
Copy linkTweet thisAlerts:
@speghettiCodeSep 23.2008 — I'm not sure about that. I'd guess "no". But I could be wrong.

What I was suggesting is to have an array of days: var daysArray = new Array('Sunday', 'Monday',...'Saturday'); and based on the int value returned from thisDate.getDay() [where: var thisDate = new Date();], you could get the text for the day you were interested in.

The top half of this page:

http://www.web-source.net/web_development/javascript_date.htm gives you everything you need to know.
Copy linkTweet thisAlerts:
@NikNakkSep 24.2008 — <i>
</i>javascript:var d=new Date();var dw=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];m=['January','February','March','April','May','June','July','August','September','October','November','December'];location.href='http://www.google.com/search?hl=en&amp;q=site%3Awww.tv.com+"Airs%3A+'+dw[d.getDay()]+'+'+m[d.getMonth()]+'+'+(d.getDate())+'%2C+'+d.getFullYear()+'"';


This should do what you want. I've created the arrays using JSON, which is the most succinct way of doing so, I think.

Nick
Copy linkTweet thisAlerts:
@tarahmarieauthorOct 26.2008 — Thank you very much! It works like a charm!
Copy linkTweet thisAlerts:
@tarahmarieauthorMay 09.2009 — Hi, all:

The tab used to work, but then tv.com changed their date format for the days a show will air. I'm trying to edit the script above to fix it, but it's not working.

Here's the script as I've edited it:

<i>
</i>javascript:var d=new Date();var dw=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];m=['January','February','March','April','May','June','July','August','September','October','November','December'];location.href='http://www.google.com/search?hl=en&amp;q=site&amp;#37;3Awww.tv.com+"Airs%3A+'+dw[d.getDay()]+'+'+m[d.getMonth()+1]+'+'+(d.getDate())+'%2C+'+d.getYear()+'"';

And here's the result:

Your search - site:www.tv.com "Airs: Saturday June 9, 109" - did not match any documents.

It needs to search for this: site:www.tv.com "Airs: 05/09/09"

I am fiddling with the script, but am a CSS/HTML gal, and I think my intuition is off on how to alter it to give me the daily updated search parameter. Any suggestions?

Thanks, all!

Tarah
×

Success!

Help @tarahmarie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...