Open kvoelker opened 10 years ago
Is anything dumped to the JavaScript Console for that tab?
I can't get javascript console to load at all. Each tab opens, then crashes. Running the console after the fact doesn't show anything. I've included a screencast so you can see what I'm seeing...
http://screencast.com/t/MfJjOPgO
kurt
Kurt Voelker Chief Technology Officer
kvoelker@forumone.com www.forumone.com 703-894-4333
_Forum One Communications_Communicate • Collaborate • Change the World
On Thu, Jan 2, 2014 at 12:02 PM, Nicolas Ward notifications@github.comwrote:
Is anything dumped to the JavaScript Console for that tab?
— Reply to this email directly or view it on GitHubhttps://github.com/UltraNurd/netflix-rater/issues/2#issuecomment-31466437 .
Hey Kurt,
Sorry about the delay in looking at this. I'm not able to replicate the error - I just tried setting some ratings with a new profile under my account, and it worked as before. Your screencast is just giving me a blank white screen, so I'm not seeing exactly what error you were getting there either. I'm wondering if there's an interaction with another extension or security setting that I don't have?
I made a fix to this problem.
Due to renewal of the layout, structure and content-delivery throughout the netflix website, the entire frame seems to be hidden behind a cross-domain iframe (from http://*.nflxext.com/). This disallows one to use javascript to click on something within that iframe.
I made a workaround, which actually works with a single url (per rating) that contains some GET requests. I stumbled upon this when browsing the site and ratings wizard for a bit. The URL looks something like this: http://www.netflix.com/SetRating?value=4&pval=4.0626845&widgetid=M70001989_XXXXXXXXXX&rtrnct=true&authURL=YYYYYYYYYYYYYYYYYYYYYYYYY§ion=RECS Where XXXXXXX refers to the accountid (not profile id) , and YYYYYY is the authenticationURL to ensure that you are who you say you are. Luckily this authenticion url is persistent for quite some time. You get there by going to: http://www.netflix.com/RatingsWizard?skgr=false&wizst=2, and copying the link address from one of the rating stars from any of the presented films or series.
I created a second json file called 'account.json' containing the accountid and authURL (extracted from the URL above). The file is read by background.js, and upon running the extension, the complete URL is formed.
So above I added:
// Load account details
var authKey;//
var accountID;//
var xhr2 = new XMLHttpRequest();
xhr2.onreadystatechange = function() {
if (xhr2.readyState == 4) {
//alert(xhr.responseText);
resp = JSON.parse(xhr2.responseText);
console.log(resp);
response = resp.shift();
console.log(response);
accountID = response.accountid;
authKey = response.authkey;
console.log(authKey + ' '+ accountID);
//alert("ratings: "+ ratings);
}
}
xhr2.open("GET", chrome.extension.getURL('/account.json'), true);
xhr2.send();
And I changed your rating function from:
// This is what does the work for a given movie
var tabIds = [];
function rate(movie) {
var starClass;
if (movie.rating == 0) {
starClass = "rvnorec";
} else {
starClass = "rv" + movie.rating;
}
console.log(movie.url + " " + starClass);
chrome.tabs.create({"url": movie.url, "active": false}, function(tab) {
console.log("Opened " + tab.id);
tabIds.push(tab.id);
if (tabIds.length > 10) {
var tabId = tabIds.shift();
console.log("Removing " + tabId);
chrome.tabs.remove(tabId);
}
chrome.tabs.executeScript(tab.id, {"code": "var star = document.getElementsByClassName('" + starClass + "')[0]; star.click();"});
});
}
to the following:
// This is what does the work for a given movie
var tabIds = [];
function rate(movie) {
//Create url
url = "http://www.netflix.com/SetRating?value="+movie.rating+"&widgetid=M"+movie.id+"_"+accountID+"&rtrnct=true&authURL="+authKey;
chrome.tabs.create({"url": url, "active": false}, function(tab) {
console.log("Opened " + tab.id+ "| "+ url);
tabIds.push(tab.id);
if (tabIds.length > 10) {
var tabId = tabIds.shift();
console.log("Removing " + tabId);
chrome.tabs.remove(tabId);
}
});
}
I know it's not the ideal solution (since one has to find his/her account id and the authentication url), but it does work very smoothly. Please consider it
Julius, can you put this into a Pull Request? Chrome isn't my primary browser anymore but I can try taking a look.
I'm getting the "Aw, Snap! Something went wrong." chrome error each time the script opens a new tab. Doesn't give any more info than that.