...

View Full Version : I'm sure this is probably a simple fix...



Track
10-08-2008, 05:06 PM
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:


// ==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:


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!

ubh
10-08-2008, 05:27 PM
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.

ohgod
10-08-2008, 05:32 PM
can you use quotes in the search string so that it will only accept that explicit combination of characters, no more or less?

Track
10-08-2008, 05:44 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum