soyguijarro / userscripts Goto Github PK
View Code? Open in Web Editor NEWUser scripts for web browsers
License: GNU General Public License v3.0
User scripts for web browsers
License: GNU General Public License v3.0
I've tried fixing this myself and I thought maybe you could also use these changes to fix the problem for other users. The root of the problem is that IMDb's source code has changed, so the Elements which had the ratings in them could not be found. All my edits are within the function getIMDbAndMetaRatings().
I changed the following variables/lines of code:
Set ratingsElt to #title-overview-widget instead of #overview-top:
ratingsElt = dom.getElementById("title-overview-widget");
Set imdbRatingElt to the correct element (the one with itemprop=ratingValue):
imdbRatingElt = ratingsElt.querySelector("[itemprop=ratingValue]");
Removed the MetaRatingMatch code and grabbed the Metascore value directly from the right element on the IMDb title page (.metacriticScore span). If the element exists, its value is parsed in the same way as the IMDb rating. removed the line where var metaRating is created, because it has already been created before. Then just update the ratings on Letterboxd (including the right metacritic URL) just as it was in the old code:
function getMetaRating() {
var metaRating,
metaRatingElt = ratingsElt.querySelector(".metacriticScore span");
if (metaRatingElt) {
metaRating = parseFloat(metaRatingElt.textContent);
GM_xmlhttpRequest({
method: "GET",
url: imdbUrl + "criticreviews", // Metacritic reviews page on IMDb
onload: function (res) {
var pageContent,
metaUrl;
dom = parser.parseFromString(res.responseText, "text/html");
pageContent = dom.getElementById("main").innerHTML;
metaUrl = pageContent.
match(/<a.*href="(.*?)".*>See all \d+ reviews/)[1];
updateRatingData("Metascore", metaRating,
metaRating / 10, metaUrl);
}
});
} else {
updateRatingData("Metascore", null);
}
}
if (ratingsElt) {
getIMDbRating();
getMetaRating();
} else {
updateRatingData("IMDb", null);
updateRatingData("Metascore", null);
}
}
I think the script didn't work anymore because IMDb made changes to their DOM. If you want to use these changes I made, you can of course do so and you can change/add/remove anything you want. I tested it and it works for me, at least.
Rotten Tomatoes rating don't works (Letterboxd Average Rating)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.