Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting jQuery and GM_addStyle to work in a Chrome userscript based off of a working Greasemonkey script
    primarykey
    data
    text
    <p>I wrote a simple <a href="http://userscripts.org/scripts/review/120111" rel="nofollow">Greasemonkey script</a> that enlarges thumbnail pictures in a flyover popup. It uses a lot of jQuery in it. It works just fine on Firefox. But not on Chrome since it doesn't support @require.</p> <p>I came across this <a href="http://erikvold.com/blog/index.cfm/2010/6/14/using-jquery-with-a-user-script" rel="nofollow">solution</a> for this matter. But the script didn't work on Chrome even after I integrated it with the get-around code. I just put all my script code inside the solution code's main function. </p> <p>Is it wrong? If anyone can point out where is the problem, and what I can do to get it right, it'll be very much appreciated. </p> <pre><code>function addJQuery(callback) { var script = document.createElement("script"); script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"); script.addEventListener('load', function() { var script = document.createElement("script"); script.textContent = "(" + callback.toString() + ")();"; document.body.appendChild(script); }, false); document.body.appendChild(script); } function main() { $("body").append ('&lt;div id="idLargePicturePopupWindow"&gt;&lt;img&gt;&lt;/div&gt;'); $('#idLargePicturePopupWindow').bind ( "mouseenter mouseleave", {bInPopup: true}, myImageHover ); $('#profPhotos .profPhotoLink &gt; img').bind ( "mouseenter mouseleave", {bInPopup: false}, myImageHover ); function myImageHover (zEvent) { if (zEvent.type == 'mouseenter') { if ( ! zEvent.data.bInPopup) { var imgurl = this.src.toString(); var bigimg = imgurl.replace(/\/thumbs\/[0-9x]+\//i, "/photos/"); $("#idLargePicturePopupWindow img").attr ('src', bigimg); } $("#idLargePicturePopupWindow").show(); } else { $("#idLargePicturePopupWindow").hide(); } } GM_addStyle ( (&lt;&gt;&lt;![CDATA[ #idLargePicturePopupWindow { position: absolute; background: white; border: none; margin: 1ex; opacity: 1.0; z-index: 1222; min-height: 100px; min-width: 200px; padding: 0; display: none; top: 2em; left: 50em; } #idLargePicturePopupWindow img { margin: 0; margin-bottom: -4px; padding: 0; } ]]&gt;&lt;/&gt;).toString () ); } addJQuery(main); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload