title: How can I setup a cross-domain call in Tampermonkey to get a divs contents
body: <p>I have been toying around with this for a few days now and I don't feel any closer to successfully gathering a string of data within a tampermonkey script. The closest I have gotten to a result was using this code <a href="http://jsfiddle.net/peterbenoit/N7avm/" rel="nofollow">http://jsfiddle.net/peterbenoit/N7avm/</a> that successfully loaded the webpage/data, but once I tried to add it as a tampermonkey script the familiar cross domain error occurred.</p>
  
  <blockquote>
    <p>Refused to load the script '<a href="http://query.yahooapis.com/v1/public/yql?q=select%20" rel="nofollow">http://query.yahooapis.com/v1/public/yql?q=select%20</a>*%20from%20html%20where…t=xml%27&amp;callback=jQuery21407879608951028498_1460047110140&amp;_=1460047110141' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval' <a href="http://steamcommunity-a.akamaihd.net/" rel="nofollow">http://steamcommunity-a.akamaihd.net/</a> <a href="https://api.steampowered.com/" rel="nofollow">https://api.steampowered.com/</a> <a href="http://www.google-analytics.com" rel="nofollow">http://www.google-analytics.com</a> <a href="https://ssl.google-analytics.com" rel="nofollow">https://ssl.google-analytics.com</a> <a href="https://www.google.com" rel="nofollow">https://www.google.com</a> <a href="https://www.gstatic.com" rel="nofollow">https://www.gstatic.com</a> <a href="https://apis.google.com" rel="nofollow">https://apis.google.com</a>".</p>
  </blockquote>
  
  <pre><code>$(function() {
  
  
      var container = $('#target');
      var msg = $('#msg');
  
  
  
      var url = 'http://peterbenoit.com';
  
      $.getJSON("http://query.yahooapis.com/v1/public/yql?" +
              "q=select%20*%20from%20html%20where%20url%3D%22" +
              encodeURIComponent(url) +
              "%22&amp;format=xml'&amp;callback=?",
      function(data) {
          if (data.results[0]) {
              var data = filterData(data.results[0]);
              msg.html('(ready.)');
              container.html(data).focus().effect("highlight", {}, 1000);
          } else {
              msg.html('(error!)');
              msg.addClass('error');
              var errormsg = '&lt;p&gt;Error: could not load the page.&lt;/p&gt;';
              container.html(errormsg).focus().effect('highlight', { color: '#c00' }, 1000);
          }
      }
    );
  
  });
  
  
  function filterData(data) {
      // filter all the nasties out
      // no body tags
      data = data.replace(/&lt;?\/body[^&gt;]*&gt;/g, '');
      // no linebreaks
      data = data.replace(/[\r|\n]+/g, '');
      // no comments
      data = data.replace(/&lt;--[\S\s]*?--&gt;/g, '');
      // no noscript blocks
      data = data.replace(/&lt;noscript[^&gt;]*&gt;[\S\s]*?&lt;\/noscript&gt;/g, '');
      // no script blocks
      data = data.replace(/&lt;script[^&gt;]*&gt;[\S\s]*?&lt;\/script&gt;/g, '');
      // no self closing scripts
      data = data.replace(/&lt;script.*\/&gt;/, '');
      // [... add as needed ...]
      return data;
  }
  </code></pre>
  
  <p>So the jist of what I am trying to do is run a personal userscript that displays content on site A and I want it to gather one string of data from a div on site B (div class="preview k_wear_float") and display it on site a within var message. I have tried iframes, JSON, xmlhttprequests and currently not had any luck whatsoever in even accessing the data so if anyone can help point me in the right direction that would be good. </p>
  
  <p>I have basic understanding of js but I am still a newbie so please explain slightly more than you would the average user if at all possible just so I can try and understand the process a bit better.</p>