When I browse netflix and activate this script it seems to request the first 3 movies (automatically) no problem. The rest which happens after a click FAIL
It's especially annoying when i make one of the pageload/automatic request exactly the same as a request after a click. The same request on the click fails and the GM_xmlhttpRequest function returned undefined. Why? How do I fix this? // ==UserScript== // @name Rotten Tomato My Netflix // @namespace sdkfjsdijfisdj // @include http://movies.netflix.com/WiGenre* // @version 1 // @grant GM_xmlhttpRequest // ==/UserScript== try{ $=unsafeWindow.jQuery; var sz='Tomato'; //sz=$('.agMovie').size(); $('#global-header').append('<li id="NetflixTomatoName" class="nav-home nav-item"><span class="i-b content"><a href="#">Name</a></span><span class="i-b shim"></span>'); $('#global-header').append('<li id="NetflixTomatoRate" class="nav-home nav-item"><span class="i-b content"><a href="#">'+sz+'</a></span><span class="i-b shim"></span>'); $('.nav-item').css('padding', '0 7px'); var hits=6; var useDummy=true; var mainText=''; function RespToInsert(htmlFromRT, j){ var el = $(htmlFromRT); el.find('#nav_primary').remove(); var html = $(el.find('#movie_results_ul .media_block')[0]).html(); j.append('<div class="TomatoRate">'+html+'</div>'); } function GetRating(name, j) { //alert(j.jquery); return; //j.append('<div class="TomatoRate">'+(encodeURI(name))+'</div>'); return; try{ if(hits==0 && useDummy && mainText!='') { RespToInsert(mainText, j); return; } hits--; alert(name); var a=function(name,j){ var gm=GM_xmlhttpRequest({ method: "GET", url: "http://www.rottentomatoes.com/search/?search=" + encodeURI(name) + "&sitesearch=rt", onload: function(response) { alert("Got " + name); mainText=response.responseText; RespToInsert(mainText, j); }, onerror: function(e){ alert('error '+e); }, onabort: function(e){ alert('abort '+e); }, ontimeout: function(e){ alert('to '+e); } }); alert(gm); };a(name,j) } catch(e) { alert(e); } } $('#NetflixTomatoName').click(function(){ $('.agMovie').each(function(i,e){ if($(e).find('.TomatoName').size()>0) return; var name = $(e).find('img.boxShotImg').attr('alt'); $(e).append('<div class="TomatoName">'+name+'</div>'); }) return false; }); $('#NetflixTomatoRate').click(function(){ $('.agMovie').each(function(i,e){ if($(e).find('.TomatoRate').size()>0) return; var name = $(e).find('img.boxShotImg').attr('alt'); GetRating(name, $(e)); }) return false; }); GetRating('raid', $('body')); GetRating('fight club', $('body')); GetRating('the matrix', $('body')); } catch(e) { alert(e); } -- You received this message because you are subscribed to the Google Groups "greasemonkey-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/greasemonkey-users. For more options, visit https://groups.google.com/groups/opt_out.
