SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Javascript modify HTML - Greasemonkey (part 2?)

    I found this thread which is really close to what I need, but not quite. It has this code:

    Code:
    (function() {
      window.addEventListener("load", function(e) {
        document.body.innerHTML = document.body.innerHTML.replace(/<((?:b);)/g, '&$1');
      }, false);
    })();
    Which turns &amp;lt; into &lt; and &amp;gt; into &gt;. My problem is the opposite as I require &lt; to be turned into < and &gt; to be changed to > as the HTML code on the page (which I don't control) is converting <b> and </b> tags into &lt;b&gt; and &lt;/b&gt;

    Is there a way to alter the above code so it makes these changes? It would be a huge help!

    Thanks

  2. #2
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    str = str.replace(/\&lt\;b\&gt;/g,"<B>");
    str = str.replace(/\&lt\;\/b\&gt;/g,"</B>");
    Got it


Bookmarks

Posting Permissions

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