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

    I'm sure this is probably a simple fix...

    I know next to nothing about coding in JS but I'm trying to tweak a script I found to do a similar function on another website.

    Here's what I've got:

    Code:
    // ==UserScript==
    // @name          Cook's Country Printer Friendly Articles
    // @description   Redirect to print friendly version of the current
    //                Cook's Country article
    // @include       https://www.cookscountry.com/*
    // ==/UserScript==
    
    (function() {
    
    if (window.location.href.match(/recipe.asp/)) {
      window.location.replace(window.location.href.replace("recipe.asp", "printrecipe.asp"));
    }
    
    })();
    The problem lies in the fact that once the script starts, it's seeing "recipe" in the new url and replacing it again and again and again... It leads to a url like this:
    Code:
    https://www.cookscountry.com/printprintprintprintprintrecipe.asp?recipeids=2476
    ..instead of just changing it one time in the url.

    Can anyone help me with this? I'm sure it's probably pretty simple to fix, but like I said, I'm clueless! Thanks a bunch!
    Last edited by Track; 10-08-2008 at 05:10 PM.

  • #2
    ubh
    ubh is offline
    Regular Coder ubh's Avatar
    Join Date
    Apr 2008
    Location
    Portland, Oregon U.S.A.
    Posts
    443
    Thanks
    108
    Thanked 15 Times in 14 Posts
    you could try changing one of the pages name, such as.

    recipe.asp printRecipe.asp

    or

    Recipe.asp printrecipe.asp

    so there is no confusion about the two.

  • #3
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    can you use quotes in the search string so that it will only accept that explicit combination of characters, no more or less?

  • #4
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by ubh View Post
    you could try changing one of the pages name, such as.

    recipe.asp printRecipe.asp

    so there is no confusion about the two.
    That worked perfectly! Thank you so much!

    --T


  •  

    Posting Permissions

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