-1

I prefer the look and feel of Firefox 2, but Youtube doesn't. None of the Greasemonkey scripts I use will work there unless I click "return to the original page" (Youtube places me on a light-weight version due to my out-of-date browser). The only difference between the pages that I could spot was a &nofeather=True at the end of the "original" url. So I decided to try and write a Greasemonkey script that would automatically re-direct me. As you can see below, I know (more or less) nothing about writing one... and though my current solution works, I've been wondering if there's a better way of doing it.

// ==UserScript==  
// @name           Youtube Redirect  
// @namespace      ??  
// @include        http://www.youtube.com/watch?v*  
// @exclude        http://www.youtube.com/watch?v*&nofeather=True  
// ==/UserScript==

(function(){  
window.location.href = window.location.href + "&nofeather=True";  
})();

Any tips would be appreciated, and thanks for your time.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Ti1
  • 1
  • 1
  • 1
  • Wait, are you still running Firefox, version 2?!   If so, you do know that that makes your machine almost wide-open to being hacked? – Brock Adams Mar 11 '11 at 05:04

2 Answers2

0

Your current script should be fine, for what it does.

Although you don't need the function wrapping, so you can change:

(function(){  
window.location.href = window.location.href + "&nofeather=True";  
})();

To:

window.location.href = window.location.href + "&nofeather=True";  

Or, per Eric's answer:

window.location.replace (window.location.href + "&nofeather=True");

-- which prevents an extra, probably undesired, page from being added to the history.


Note that all of this works on modern versions of FF and GM. (Probably works on the obsolete versions, too; but I might have forgotten some old bug in that older stuff.)


However, using GM for redirects is not best, because most of the page has to load before GM fires. So, you are loading pages twice every time! (Not counting some images.)

A better approach would be to use an extension specifically designed for redirecting. You'll get a snappier response.

Redirector is a fine add-on. But it requires you to have an up-to-date version of Firefox -- which you should do anyway! (unless you like your machine secretely sending out spam without your knowledge? :) )

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
0

I would do window.location.replace(newURLHere) so that your back button still works.

erikvold
  • 15,988
  • 11
  • 54
  • 98