0

I wanted to make a bookmarklet that changes the current YouTube URL to its equivalent on listenonrepeat.com, so I could repeat the video. I have a bookmark in my bookmarks bar with the following javascript:

javascript:window.location=window.location.href.replace("youtube","listenonrepeat");

Yet it won't change it unless I copy and paste it into the URL bar. Safari 6.

Can be seen here: http://christianselig.com/youtubefix.html

Doug Smith
  • 29,668
  • 57
  • 204
  • 388
  • Try using: `javascript:window.location.href=window.location.href.replace("youtube","listenonrepeat"); ` – mowwwalker Nov 20 '12 at 00:29
  • Try changing the double quotes (`"`) to single (`'`) and adding `.href` to the first `window.location`. – joequincy Nov 20 '12 at 00:30
  • Didn't work. The code is available here: christianselig.com/youtubefix.html – Doug Smith Nov 20 '12 at 00:32
  • 2
    Your URL has some strange stuff in it. Are you sure you wrote it in a programming editor? `javascript:window.location.href=window.location.href.replace('youtube','listeno‌​nrepeat');` – Blender Nov 20 '12 at 00:35

1 Answers1

0

Replacing the url and embedding it into a function, like the code below, makes it open a new window directly into listenonrepeat:

javascript:(function(win){win.open(win.location.href.replace("youtube","listenonrepeat"));})(window)
aderubaru
  • 399
  • 6
  • 8