Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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]

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    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.

  • #5
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    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>
    Last edited by rnd me; 01-25-2013 at 02:52 PM.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •