Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6065749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:25:33+00:00 2026-05-23T09:25:33+00:00

In some forum I join, they just replace some link with something like spam

  • 0

In some forum I join, they just replace some link with something like spam or deleted. Example: http://www.rapidshare.com/download/123 will automatically turn to http://www.spam.com/download/123 OR word MONEY will change to BOSS.

Its really annoyed me because I have to rename back manually if I want to download. Is there any Javascript that can solve this that will replace back http://www.spam.com to http://www.rapidshare.com? I mean in client side.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:25:33+00:00Added an answer on May 23, 2026 at 9:25 am

    If these URLs are in href attributes…

    var replaceHrefAttributes = function (element, search, replace) {
        var nodes = element.getElementsByTagName('a');
    
        for (var i = 0, length = nodes.length; i < length; i++) {
    
            var node = nodes[i];
    
            if (node.href == undefined) {
                continue;
            }
    
            node.href = node.href.replace(new RegExp(search, 'g'), replace);
        }
    
    }
    

    Your usage may be something like…

    replaceHrefAttributes(document.body, 'www.spam.com', 'www.rapidshare.com');
    

    If these URLs are inline text…

    You could iterate over all text nodes, using replace() to replace any string with another.

    Here is a general purpose recursive function I’ve written to do this…

    var replaceText = function replaceText(element, search, replace) {
        var nodes = element.childNodes;
    
        for (var i = 0, length = nodes.length; i < length; i++) {
    
            var node = nodes[i];
    
            if (node.childNodes.length) {
                replaceText(node, search, replace);
                continue;
            }
    
            if (node.nodeType != 3) {
                continue;
            }
    
            node.data = node.data.replace(new RegExp(search, 'g'), replace);
        }
    
    }
    

    Your usage may be something like…

    replaceText(document.body, 'www.spam.com', 'www.rapidshare.com');
    

    If you are curious as to how the code works, here is a brief explanation…

    1. Get all child nodes of the element. This will get text nodes and elements.
    2. Iterate over all of them.
    3. If this node has child nodes of its own, call the function again with element as the element in the loop. continue because we can’t modify this as it is not a text node.
    4. If this node’s nodeType property is not 3 (i.e. a text node), then continue as again we can’t modify any text.
    5. We are confident this is a text node now, so replace the text.

    You could make this function more flexible by passing search straight to it, allowing it to search for text using a string or a regular expression.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have html like so: <div class=foo> (<a href=forum.example.com>forum</a>) <p> Some html here.... </div>
I just came over this syntax in some of the questions in this forum,
I am creating some tag functionality for a forum using linq2sql, and I have
I'm building a basic forum where every post contains some text, first and last
This is a question I asked on another forum which received some decent answers,
For some reason my submit button isn't centered. http://prime.programming-designs.com/test_forum/viewboard.php?board=0 #submitbutton{ margin: auto; border: 1px
Im facing some problems, I looked around in the forum and didnt find any
I'm creating a basic forum where every message contains the authors name, some text
im using a while loop to show my latest forum topics and count some
For some reason this test is failing and it's something to do with when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.