Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-24-2013, 08:31 PM   PM User | #1
nickodemos
New to the CF scene

 
Join Date: Jan 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
nickodemos is an unknown quantity at this point
IMDB button to open page to weblink

This is a standard IMDB link: http://www.imdb.com/title/tt0066049/

The website I am on helps populate movies information through a scripting addon, but now that IMDB has added things to the end of its links it has messed things up. Example:
http://www.imdb.com/title/tt0066049/?ref_=fn_al...

I was wondering if anyone could make a JS that could be made as a bookmark that would strip out everything except the numbering (0066049) and add a link to website and open that page.

Stepping through it.
1. Find the IMDB website address that I am currently viewing. http://www.imdb.com/title/tt0066049/?ref_=fn_al...
2. Strip out everything but 0066049
3. Add link to the name http://www.mywebsite.com/imdb.php?mid=0066049
4. Open page to that link.

I got the idea from a TinyUrl bookmarklet I use

[CODE].open(%22http:\//tinyurl.com/create.php?url=%22+location.href.replace(/#/,'%23'),'','toolbar=no,location=no,%20directories=no,%20status=yes,%20menubar=no[\CODE]
nickodemos is offline   Reply With Quote
Old 01-24-2013, 10:17 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,063 Times in 4,032 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Ummm...the problem is, JavaScript is *NOT ALLOWED* to look at *ANYTHING* relating to a page on *another* web site.

So if you are viewing a page on the IMDB web site (and you did say "...that I am currently viewing..."), the only way to do this would be to be able to add code *TO IMDB's PAGE*.

Now, you *can* do that with (for example) a CHROME extension. But that means it will only work on your own machine (or at least only on machines where you manage to convince people to install the extension...and good luck with that unless they are *VERY* good friends of yours).
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 01-25-2013, 12:15 AM   PM User | #3
nickodemos
New to the CF scene

 
Join Date: Jan 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
nickodemos is an unknown quantity at this point
Quote:
Originally Posted by Old Pedant View Post
Ummm...the problem is, JavaScript is *NOT ALLOWED* to look at *ANYTHING* relating to a page on *another* web site.
Not looking for it to look at another site. Just asking it to open a link. A static link with the requested numbers added to the end. This is on a private site so no one but members would be able to use it. This will be posted in the websites forum for people who upload content. This will be a kluge till the script addon for the website gets updated.

I have been a moderator on the site for four years. So yes, most people who are there would trust me, for I am trying to get them this work around.
nickodemos is offline   Reply With Quote
Old 01-25-2013, 01:12 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,063 Times in 4,032 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Okay, so either Firefox or Chrome can do this. Firefox uses something called "GreaseMonkey". Chrome just calls it "Chrome Extensions".

I would personally opt for Chrome, as I find their debugger easier to use than Firebug.

Note that all your users will not only have to download and install the extension but will also have to, of course, use the Chrome browser.

You can use Google to find "chrome extensions". Not a lot different than writing JS code within a page, really.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 01-25-2013, 02:48 PM   PM User | #5
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,554
Thanks: 9
Thanked 480 Times in 463 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
Code:
alert(
  [].slice.call(document.links)
   .filter(/./.test, /\/tt\d{7}\//i)
   .map(function(a){
       return  "share".link("http://www.mywebsite.com/imdb.php?mid="+a.href.match(/(tt\d{7})/)[0]) ;
   })
   .filter(function(a,b,c){return c.indexOf(a)===b;}) /* optional line to get unique results, remove to get all */
   .join("\n\n")
)


// result on this page (using firebug): 
//     <a href="http://www.mywebsite.com/imdb.php?mid=tt0066049">share</a>
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:15.2% IE7:0.5% IE8:8.4% IE9:8.5% IE10:8.5%

Last edited by rnd me; 01-25-2013 at 02:52 PM..
rnd me is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:52 AM.


Advertisement
Log in to turn off these ads.