Welcome to the ICM Forum. If you have an account but have trouble logging in, or have other questions, see THIS THREAD.
Podcast: Talking Images (Episode 11 released July 24th)
Polls: 0 Official Lists (Results), 1960 (Aug 9th), Romance (Aug 28th)
Challenges: German/Austrian/Swiss, <400, 1970s
Film of the Week: Sibiriada, September nominations (Aug 28th)
World Cup S4: Match 2G: Russia vs Portugal (Aug 6th), Match 2H: India vs Cuba (Aug 16th), QF Preparation (Aug 25th)

iCheckMovies Enhanced

Post Reply
User avatar
Onderhond
Posts: 4515
Joined: Dec 23, 2012
Contact:

Re: iCheckMovies Enhanced

#241

Post by Onderhond » April 21st, 2020, 1:53 pm

Okay, so not sure what's in the official ICM Enhanced script or if it still being maintained, but I wanted to tamper a bit more with TamperMonkey and wrote myself something extra that gives me additional personalized stats on the list pages. Stuff that often comes up in the forum lists and that gives a quick, broader overview of how I relate to a certain list.

So now I have this:
Image

Here's the script, for people who want it. Also if this is not part of the ICM Enhanced script yet and someone wants to add it, by all means do so! Code isn't very clean, but should be functional and tested against at least some edge cases.

Code: Select all

// ==UserScript==
// @name         ICM enhancements
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://*.icheckmovies.com/lists/*
// @grant        none
// ==/UserScript==
let filmList = document.getElementById('itemListMovies');
let filmListItems = filmList.querySelectorAll('.listItem');
let filmListTotal = filmListItems.length;
let checkedTotal = filmList.querySelectorAll('.listItem.checked').length;

// extra list info
let uncheckedCount = filmList.querySelectorAll('.listItem.unchecked').length;
let highestUnchecked = '';
let highestUncheckedRank = '';
if (uncheckedCount > 0) {
    highestUnchecked = filmList.querySelector('.listItem.unchecked h2 a').innerHTML;
    highestUncheckedRank = '#' + filmList.querySelector('.listItem.unchecked .rank').childNodes[0].nodeValue.trim();
} else {
    highestUnchecked = 'All checked!';
    highestUncheckedRank = 'n/a';
}
let favoriteCount = filmList.querySelectorAll('.listItem.favorite').length;
let highestFavorite = '';
let highestFavoriteRank = '';
if (favoriteCount > 0) {
    highestFavorite = filmList.querySelector('.listItem.favorite h2 a').innerHTML;
    highestFavoriteRank = '#' + filmList.querySelector('.listItem.favorite .rank').childNodes[0].nodeValue.trim();
} else {
    highestFavorite = 'None found';
    highestFavoriteRank = 'n/a';
}
let hateCount = filmList.querySelectorAll('.listItem.hated').length;
let highestHate = '';
let highestHateRank = '';
if (hateCount > 0) {
    highestHate = filmList.querySelector('.listItem.hated h2 a').innerHTML;
    highestHateRank = '#' + filmList.querySelector('.listItem.hated .rank').childNodes[0].nodeValue.trim();
} else {
    highestHate = 'None found';
    highestHateRank = 'n/a';
}

let unofficialCount = 0;
let isOfficial = (document.getElementById('topList').querySelector('h4.compact').innerHTML.trim().includes('An official iCheckMovies list')) ? true : false;
let officialLabel = (isOfficial) ? 'Unique officials' : 'Unofficial films';
for (let k=0; k < filmListItems.length; ++k) {
    let info = filmListItems[k].querySelector('.info');
    let officialListCounter = info.querySelectorAll('a')[1];

    if (isOfficial && officialListCounter !== undefined) {
        if (officialListCounter.innerHTML.charAt(0) == '1' && officialListCounter.innerHTML.charAt(1) == ' ') {
            unofficialCount += 1;
        }
    } else {
        if (officialListCounter.innerHTML.charAt(0) == '0') {
            unofficialCount += 1;
        }
    }
}


let extraInfo = '<div class="ohExtraInfo">';
extraInfo += '<div class="spec"><div class="label">Highest unchecked</div><div class="value">' + highestUnchecked + ' (' + highestUncheckedRank + ')</div></div>';
extraInfo += '<div class="spec"><div class="label">Number of favorites</div><div class="value">' + favoriteCount + '/' + checkedTotal + ' (' + Math.round((favoriteCount/checkedTotal)*100) + '%)</div></div>';
extraInfo += '<div class="spec"><div class="label">Highest favorite</div><div class="value">' + highestFavorite + ' (' + highestFavoriteRank + ')</div></div>';
extraInfo += '<div class="spec"><div class="label">Number of dislikes</div><div class="value">' + hateCount + '/' + checkedTotal + ' (' + Math.round((hateCount/checkedTotal)*100) + '%)</div></div>';
extraInfo += '<div class="spec"><div class="label">Highest dislike</div><div class="value">' + highestHate + ' (' + highestHateRank + ')</div></div>';
extraInfo += '<div class="spec"><div class="label">' + officialLabel + '</div><div class="value">' + unofficialCount + '/' + filmListTotal + ' (' + Math.round((unofficialCount/filmListTotal)*100) + '%)</div></div>';
extraInfo += '</div>';
extraInfo += '<style>.ohExtraInfo {margin-bottom:20px;} .spec {display:flex; margin:4px 0;}.spec .label {font-weight:700; flex-basis:160px;}';
let printExtraLocation = document.getElementById('itemContainer');
printExtraLocation.insertAdjacentHTML('beforebegin', extraInfo);

User avatar
xianjiro
Donator
Posts: 7750
Joined: Jun 17, 2015
Location: Kakistani Left Coast
Contact:

#242

Post by xianjiro » April 22nd, 2020, 2:03 am

nice! :thumbsup: :cheers:

Listen, Daddy. Teacher says, 'every time a car alarm bleeps, into heaven a demon sneaks.'
sol can find me here

User avatar
mightysparks
Site Admin
Posts: 30725
Joined: May 05, 2011
Location: Perth, WA, Australia
Contact:

#243

Post by mightysparks » April 22nd, 2020, 2:44 am

Onderhond, I noticed it doesn't work on this list: https://www.icheckmovies.com/lists/thri ... flavo5000/

Idk if it's clashing with another script or some other issue but it's worked fine on all other lists so far.
"I do not always know what I want, but I do know what I don't want." - Stanley Kubrick

iCM | IMDb | LastFM | TSZDT

Image

User avatar
Onderhond
Posts: 4515
Joined: Dec 23, 2012
Contact:

#244

Post by Onderhond » April 22nd, 2020, 5:41 am

mightysparks wrote:
April 22nd, 2020, 2:44 am
Onderhond, I noticed it doesn't work on this list: https://www.icheckmovies.com/lists/thri ... flavo5000/

Idk if it's clashing with another script or some other issue but it's worked fine on all other lists so far.
Hmmm, it works for me, but could be some edge case I haven't covered yet related to your personal checks/likes. Anything special about your stats of that list (no favorites, none/all checked, ...) Stuff like that? :)

Weird list btw, 80-90% of that seems to be TV series? :)

User avatar
mightysparks
Site Admin
Posts: 30725
Joined: May 05, 2011
Location: Perth, WA, Australia
Contact:

#245

Post by mightysparks » April 22nd, 2020, 6:16 am

Onderhond wrote:
April 22nd, 2020, 5:41 am
mightysparks wrote:
April 22nd, 2020, 2:44 am
Onderhond, I noticed it doesn't work on this list: https://www.icheckmovies.com/lists/thri ... flavo5000/

Idk if it's clashing with another script or some other issue but it's worked fine on all other lists so far.
Hmmm, it works for me, but could be some edge case I haven't covered yet related to your personal checks/likes. Anything special about your stats of that list (no favorites, none/all checked, ...) Stuff like that? :)

Weird list btw, 80-90% of that seems to be TV series? :)
It's working now :/ I refreshed it and reopened it a couple times before and it didn't load, but now it's fine :shrug: But nothing special about this list. It was working ok on lists with 0 of everything etc.
"I do not always know what I want, but I do know what I don't want." - Stanley Kubrick

iCM | IMDb | LastFM | TSZDT

Image

User avatar
Onderhond
Posts: 4515
Joined: Dec 23, 2012
Contact:

#246

Post by Onderhond » April 22nd, 2020, 8:23 am

Might be some conflict with other scripts then. Not sure what browser you're using, but if you press F12 on the page where it fails a technical inspector window should pop up. There is a tab "console" where the errors will be logged :)

User avatar
Fergenaprido
Donator
Posts: 4164
Joined: Jun 03, 2014
Location: Malaysia
Contact:

#247

Post by Fergenaprido » April 24th, 2020, 3:55 am

Onderhond wrote:
April 21st, 2020, 1:53 pm
Okay, so not sure what's in the official ICM Enhanced script or if it still being maintained, but I wanted to tamper a bit more with TamperMonkey and wrote myself something extra that gives me additional personalized stats on the list pages. Stuff that often comes up in the forum lists and that gives a quick, broader overview of how I relate to a certain list.


Here's the script, for people who want it. Also if this is not part of the ICM Enhanced script yet and someone wants to add it, by all means do so! Code isn't very clean, but should be functional and tested against at least some edge cases.
This is really cool. Thanks for putting this together Onderhond. :)

Post Reply