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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Greasemonkey script issue

    Hello Everyone! I'm new to JavaScript. I thought of learning by doing instead of just reading tutorials and books. So I started writing a Greasemonkey script for Facebook.

    Basically what it does is it creates a link to download photo albums from Facebook. I'm far from finished but anyway, here's my code so far.

    The format of the HTML code block where the URLs of pics are.

    Code:
    <div class="tagWrapper">
    <i style="background-image: url(https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/299595_10150290138650735_543370734_8021370_355110168_a.jpg);"></i>
    </div>
    And here's my script so far,

    Code:
    var picURL;
    var modURL;
    var URLset = [];
    
    for(var i=0; i<picURL.length; i++)
    {
        //gets all the URLs in the page
        picURL = document.getElementsByClassName("tagWrapper")[0].children[0].style.backgroundImage;
        modifyURL(picURL);
        URLset.push(modURL);  //inserting them to an array
        
        alert(URLset) ;
    }
    
    function modifyURL();
    {
        //doing the replacements to make them downloadable
        modURL = picURL.replace("url(", "").replace(")", "");
        modURL = modURL.replace("a.jpg", "n.jpg");
        var dwn = "?dl=1";
        modURL = modURL.concat(dwn);
        
        return modURL;
    }
    I have created a fiddle so that it all would be clearer.

    Since I'm half way through it, I just want to make sure it works up to this point so I have put an alert box to show all the modified URLs stored in the array. (supposed to, at least) the problem is, it isn't showing up.

    Can anyone please tell me what I have done wrong here? Bare with me for I'm new to this as I've mentioned earlier. Any help in teh right direction would be much appreciated.

    Thanks in advance.

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,280
    Thanks
    12
    Thanked 343 Times in 339 Posts
    just do what Atli explained.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Tags for this Thread

    Posting Permissions

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