title: How can I replace the text in JSON string with a userscript for Greasemonkey
body: <p>I want to create a user script for Greasemonkey in Firefox without using jQuery, which can replace old text by new text when the page of website is loaded.</p>
  
  <p>HTML code:</p>
  
  <pre><code>..
  
  window.app = profileBuilder({
  ..
      "page": {
          "btn": {
              "eye": "blue",
              "favorite_color": "blue",
              "gender": "male",
          },
      },
  ..
  });
  
  ..
  </code></pre>
  
  <p>Replace "blue" of eye by "green", "blue" of favorite color by "red" and "male" by "female".</p>
  
  <p>When the page will be loaded, I want to see, for instance Green (not Blue) for Eye and Female for Gender (not Male).</p>
  
  <p>I guess I need to use functions next:</p>
  
  <pre><code>GM_getValue()
  GM_setValue()
  JSON.parse()
  JSON.stringify()
  </code></pre>
  
  <p>PS: the code JSON is directly in the page and not in file (../code.json)</p>
  
  <p>Userscript code:</p>
  
  <pre><code>// ==UserScript==
  // @name        nemrod Test
  // @namespace   nemrod
  // @include     http*://mywebsite.com/*
  // @version     1
  // ==/UserScript==
  var json = {"page": {"btn": {"eye": "blue","favorite_color": "blue","gender": "male",},},};
  var stringified = JSON.stringify(json);
  stringified = stringified.replace(/"eye": "blue"/gm, '"eye": "green"');
  stringified = stringified.replace(/"favorite_color": "blue"/gm, '"favorite_color": "red"');
  var jsonObject = JSON.parse(stringified);
  </code></pre>
  
  <p>It doesn't work</p>
  
  <p>Can somebody help with the right code?</p>