title: jQuery UI dialog in Bookmarklet and GreaseMonkey
body: <p>Thanks to some awesome answers in other threads, I learned how to:  </p>
  
  <ul>
  <li><a href="https://stackoverflow.com/a/6551184/1596418">load jQuery and jQuery-UI in a bookmarklet</a>  </li>
  <li><a href="https://stackoverflow.com/a/805406/1596418">load a CSS into a bookmarklet using jQuery</a>  </li>
  <li><a href="https://stackoverflow.com/a/8332887/1596418">create a DIV in a bookmarklet using jQuery</a>  </li>
  <li><a href="http://jqueryui.com/dialog/" rel="nofollow noreferrer">create jQuery UI dialog (external link)</a></li>
  </ul>
  
  <p>and I could manage to combine all four things into a single script which works both as a BookMarklet and as a GreaseMonkey script, which is absolutely awesome.</p>
  
  <p>However, it doesn't work on all sites. Neither the bookmarklet nor the GreaseMonkey script work on Wikipedia. 
  I tried it on other sites and it works: amazon.com, msn.com, yahoo.com, news.google.com, stackoverflow.com and it works well.</p>
  
  <p>Is it possible to make it work on wikipedia.org?</p>
  
  <p>Also there is a minor issue: each second time I use the bookmarklet, the title of the dialog window doesnt show ('Basic dialog'). I wonder why, although it doesn't really matter - it's not important at all.</p>
  
  <p>Here is the script:</p>
  
  <pre><code>javascript:(function () {
          function getScript(url, success) {
              var script = document.createElement('script');
              script.src = url;
  
              var head = document.getElementsByTagName('head')[0];
              var completed = false;
              script.onload = script.onreadystatechange = function () {
                  if (!completed &amp;&amp; (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
                      completed = true;
                      success();
                      script.onload = script.onreadystatechange = null;
                      head.removeChild(script);
                  }
              };
              head.appendChild(script);
          }
  
          getScript("https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js", function () {
              getScript("https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.js", function () {
                  var myStylesLocation = "https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css";
                  $('&lt;link rel="stylesheet" type="text/css" href="'+myStylesLocation+'" &gt;').appendTo("head");
                  alert("It works");
                  var myMessage = "This is the default dialog which is useful for displaying information.";
                  $("&lt;div id='dialog'; title='Basic dialog'; style='border:2px solid black; background-color:lightblue; font-size:80%'; &lt;p&gt;" + myMessage + "&lt;/p&gt;&lt;/div&gt;").appendTo("body");
                  $( "#dialog" ).dialog();
              });
          });
  })();
  </code></pre>