Forum Settings
Forums
New
Jun 16, 2020 8:32 PM
#1

Offline
Apr 2020
981
I have 2 ideas about scripting in MAL

1st is converting watch time from days to hours
2nd is adding "drop percentage" (drop divided by completed) label in anime page

any simple way to fetch those data, especially for a complete beginner ?



Pages (2) [1] 2 »
Jun 16, 2020 9:36 PM
#2

Offline
May 2018
1814
// ==UserScript==
// @name Days to Hours and stats in %
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Days to Hours and stats in %
// @author Me
// @match https://myanimelist.net/profile/*
// @run-at document-end
// @grant GM_addStyle
// ==/UserScript==

(function(){
GM_addStyle(".profile .user-statistics .stats-status{width: 200px;}");
const time = document.querySelector(".di-tc.al.pl8.fs12.fw-b"),
timeType = time.querySelector("span"),
timeValueNode = timeType.nextSibling,
timeValue = parseFloat(timeValueNode.textContent.replace(/,/g,""));

timeType.textContent = "Hours: ";
timeValueNode.textContent = (timeValue * 24).toFixed(1);

const total = parseInt(document.querySelector(".stats-data.fl-r span:nth-child(2)").textContent.replace(/,/g,""));
const [watching,completed,onHold,dropped,planToWatch] = document.querySelectorAll(".di-ib.fl-r.lh10");

[watching,completed,onHold,dropped,planToWatch].forEach(addPercentage);

function getPercentage(node) {
const value = parseInt(node.textContent.replace(/,/g,""));
if(total === 0) return "0.00";
return (value*100/total).toFixed(2);
}

function addPercentage(node) {
const percentage = getPercentage(node);
node.textContent = `${node.textContent} (${percentage}%)`;
}
})()
Only_BradJun 27, 2020 12:15 PM
Jun 16, 2020 9:43 PM
#3

Offline
Apr 2020
981
Only_Brad said:
for the time watched in hours in your profile, you can use that.

// ==UserScript==
// @name Days to Hours
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Days to Hours
// @author Me
// @match https://myanimelist.net/profile/*
// @run-at document-end
// ==/UserScript==

(function(){
const time = document.querySelector(".di-tc.al.pl8.fs12.fw-b");
const timeType = time.querySelector("span");
const timeValueNode = timeType.nextSibling;
const timeValue = parseFloat(timeValueNode.textContent);

timeType.textContent = "Hours: ";
timeValueNode.textContent = (timeValue * 24).toFixed(1);
})()





it's working
thank you very much !

Jun 17, 2020 5:05 PM
#4

Offline
Dec 2019
3519
Only_Brad said:
for the time watched in hours in your profile, you can use that.

// ==UserScript==
// @name Days to Hours
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Days to Hours
// @author Me
// @match https://myanimelist.net/profile/*
// @run-at document-end
// ==/UserScript==

(function(){
const time = document.querySelector(".di-tc.al.pl8.fs12.fw-b");
const timeType = time.querySelector("span");
const timeValueNode = timeType.nextSibling;
const timeValue = parseFloat(timeValueNode.textContent);

timeType.textContent = "Hours: ";
timeValueNode.textContent = (timeValue * 24).toFixed(1);
})()





Drop percentage is not working. Can you make the codes to show the percentagens for the whole bar? (completed etc)
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 17, 2020 10:07 PM
#5

Offline
May 2018
1814
@hacker09 @epsilon4

I've changed the code, now you can see the % of watching, dropped, completed etc. in your profile.
Jun 18, 2020 4:19 AM
#6

Offline
Feb 2019
996
Thanks, pretty useful. I much prefer it over the days counter.
Jun 18, 2020 6:39 AM
#7

Offline
Dec 2019
3519
Only_Brad said:
@hacker09 @epsilon4

I've changed the code, now you can see the % of watching, dropped, completed etc. in your profile.


Thanks you so much, but it seems that something is really wrong


I can't understand what these percentages mean...
By show the percentage of everything I meant, calculate the total Entries and then show in percentages how much of these total entries are completed etc in percentages...
So the maximum percentage is 100% that is the Total Entries. Then this 100% should be splitted into the completed etc
hacker09Jun 18, 2020 6:42 AM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 18, 2020 8:44 AM
#8

Offline
May 2018
1814
hacker09 said:
Only_Brad said:
@hacker09 @epsilon4

I've changed the code, now you can see the % of watching, dropped, completed etc. in your profile.


Thanks you so much, but it seems that something is really wrong


I can't understand what these percentages mean...
By show the percentage of everything I meant, calculate the total Entries and then show in percentages how much of these total entries are completed etc in percentages...
So the maximum percentage is 100% that is the Total Entries. Then this 100% should be splitted into the completed etc


I fixed the code, it should be working now. The total is the sum of everything on the left (Watching, completed, on-hold, dropped, plan to watch). There were 2 bugs in the previous code: bad css selector and I didn't take into account the commas in the numbers which caused errors when converting the number from a string to a real number.

Only_BradJun 18, 2020 8:48 AM
Jun 18, 2020 9:16 AM
#9

Offline
Dec 2019
3519
Only_Brad said:
hacker09 said:


Thanks you so much, but it seems that something is really wrong


I can't understand what these percentages mean...
By show the percentage of everything I meant, calculate the total Entries and then show in percentages how much of these total entries are completed etc in percentages...
So the maximum percentage is 100% that is the Total Entries. Then this 100% should be splitted into the completed etc


I fixed the code, it should be working now. The total is the sum of everything on the left (Watching, completed, on-hold, dropped, plan to watch). There were 2 bugs in the previous code: bad css selector and I didn't take into account the commas in the numbers which caused errors when converting the number from a string to a real number.



Thank you,that's really nice.



There's a 00.1 of error but now I can say that the script is perfect!

Do you know if it's possible to do a program like you did, but that automatically detects all the overall rating from the reviews of all users for specific animes?

I mean when I open the review page of an anime like this for example
https://myanimelist.net/anime/40591/Kaguya-sama_wa_Kokurasetai__Tensai-tachi_no_Renai_Zunousen/reviews

The script calculates the overrall rating of all users that reviewed that anime,calculates an then show somewhere the average rating of all users overall rating.
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 18, 2020 9:25 AM

Offline
May 2018
1814
Yeah it's rounding error
Jun 18, 2020 11:05 AM

Offline
Dec 2019
3519
Only_Brad said:
Yeah it's rounding error

hmm,but just 0.01% isn't a big problem I guess.

Do you know if it's possible to do a program like you did, but that automatically detects all the overall rating from the reviews of all users for specific animes?
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 18, 2020 1:08 PM

Offline
May 2018
1814
hacker09 said:
Only_Brad said:
Yeah it's rounding error

hmm,but just 0.01% isn't a big problem I guess.

Do you know if it's possible to do a program like you did, but that automatically detects all the overall rating from the reviews of all users for specific animes?


Here's what I've made:

When you go to the review tab you will see a text saying that it is calculating the average, it takes a little bit of time because you have to scrap all the review pages in order to get all the review scores, the less review pages there are the faster it will load the average score. In my example it had to download 5 more reviews pages.







// ==UserScript==
// @name Average Reviews
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Average Reviews
// @author Me
// @include /^https:\/\/myanimelist\.net\/(anime|manga)\/[\d]+\/.*\/reviews/
// @run-at document-end
// @grant GM_addStyle
// ==/UserScript==
(async function(){
const
REVIEWS_TAB_SELECTOR = "#content > table > tbody > tr > td:nth-child(2) > div.js-scrollfix-bottom-rel",
SCORE_TABLES_SELECTOR = "table.borderClass",
OVERALL_RATING_SELECTOR = "tbody > tr > td:nth-child(2) > strong",
SEPERATOR_SELECTOR = ".reviews-horiznav-nav-sort-block";

const
currentUrl = window.location.href,
firstPageUrl = getFirstPageUrl(),
currentPage = getCurrentPage(),
score = setPlaceholderScore();

showAverageOverallScore();

function setPlaceholderScore() {
const separator = document.querySelector(SEPERATOR_SELECTOR);
const score = document.createElement("div");
score.style = "padding: 15px 0 15px 10px;";
score.textContent = "Calculating total average review score...";
separator.insertAdjacentElement("afterend",score);
return score;
}

async function showAverageOverallScore() {
const overallScores = await getAllOverallScore();
const average = overallScores.reduce((acc,val)=>acc+val,0)/overallScores.length;
score.textContent = "Average score: "+average.toFixed(2);
}

async function getAllOverallScore() {
const overallScores = [];

for(let i=1;;i++) {
const currentDocument = await getDocument(i);
if(hasReviews(currentDocument)) {
overallScores.push(getOverallScores(currentDocument));
}
else return overallScores.flat();
}
}

async function getDocument(pageNumber) {
let currentDocument;
if(pageNumber === currentPage) currentDocument = document;
else {
const url = pageNumber === 1 ? firstPageUrl : `${firstPageUrl}?p=${pageNumber}`;
const response = await fetch(url);
const html = await response.text();
currentDocument = new DOMParser().parseFromString(html,"text/html");
}
return currentDocument;
}

function getOverallScores(document) {
const reviewsTab = document.querySelector(REVIEWS_TAB_SELECTOR);
const scoreTables = reviewsTab.querySelectorAll(SCORE_TABLES_SELECTOR);
return [...scoreTables].map(table => parseInt(table.querySelector(OVERALL_RATING_SELECTOR).textContent));
}

function hasReviews(document) {
const reviewsTab = document.querySelector(REVIEWS_TAB_SELECTOR);
const scoreTables = reviewsTab.querySelectorAll(SCORE_TABLES_SELECTOR);
return scoreTables.length > 0;
}

function getFirstPageUrl() {
const PAGE_REGEX = /\?p=[\d]+/;
const search = currentUrl.search(PAGE_REGEX);

if(search !== -1) return currentUrl.substring(0,search);
return currentUrl;
}

function getCurrentPage() {
const PAGE_REGEX = /\?p=([\d]+)/;
const match = currentUrl.match(PAGE_REGEX);

if(match) return parseInt(match[1]);
else return 1;
}
})()
Only_BradJun 18, 2020 1:24 PM
Jun 18, 2020 1:22 PM

Offline
Dec 2019
3519
@Only_Brad

Wow my Gosh! That's so nice! You're such a nice person!
Also thank you so much for adding me as a friend,If you want to talk or any kind of help just talk with me.
hacker09Jun 29, 2020 8:12 PM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 18, 2020 7:42 PM

Offline
May 2019
3444
Only_Brad said:
@hacker09 @epsilon4

I've changed the code, now you can see the % of watching, dropped, completed etc. in your profile.


Thanks a lot, amazing job in this thread!


And just like the average reviews, would be nice a script to show this same % not just of our profiles, but of any anime entry when you check its stats.


For example:



Thanks again!


Edit.
Rob7Jun 19, 2020 7:44 AM
Jun 19, 2020 3:54 AM
Offline
Jul 2018
561874
the gods have heard my plight ಥ‿ಥ

this is very welcome; @Only_Brad thanks for your time mate.


@hacker09 now please code a program to scrape those aggregated scores into a ranking list that updates every few days or so 😂


jk though we'll get there eventually! ༎ຶ‿༎ຶ
Jun 19, 2020 6:25 AM

Offline
Dec 2019
3519
@Rob7

hmm,that's not really needed I think.That would be just a little bit nice.The Score Stats already have percentages,so you are talking about the summary stats right?
hacker09Jun 29, 2020 8:13 PM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 19, 2020 6:29 AM

Offline
Dec 2019
3519
@Korishi

HAHAHAHA,me and Only_Brad are not Gods haha.

So actually you didn't want the average scores of the reviews, you just want to know specifically the total number of reviews and the total number of people that scored the anime in the scale of 1 to 10?
(Example: total reviews 199.
total reviews scored with 1 50 people
total reviews scored with NUMBERS...)

If that's what you want the JS program is "half done". But as I was saying, It's better to save all the scrapped data on excel than saving it "on the JS" on somewhere on your browser.
I also don't think that would be easy neither good to make the JS update the excel or re-scrape and re-download the scrapped content in another excel file, would be better and easier if you always opened the review for the anime that you want to update the excel scrapped file.
hacker09Jun 29, 2020 8:14 PM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 19, 2020 7:46 AM

Offline
May 2019
3444
hacker09 said:


hmm,that's not really needed I think.That would be just a little bit nice.The Score Stats already have percentages,so you are talking about the summary stats right?



Exactly, the summary stats. I edited the print to make it clear.

The dropping rate is also important to compare the quality of works.
Rob7Jun 19, 2020 7:50 AM
Jun 19, 2020 7:52 AM

Offline
Dec 2019
3519
Rob7 said:
hacker09 said:


hmm,that's not really needed I think.That would be just a little bit nice.The Score Stats already have percentages,so you are talking about the summary stats right?



Exactly, the summary stats. I edited the print to make it clear.

The dropping rate is also important to compare the quality of works.


Yes know I got it,thanks
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 19, 2020 8:54 AM
Offline
Jul 2018
561874
hacker09 said:


So actually you didn't want the average scores of the reviews, you just want to know specifically the total number of reviews and the total number of people that scored the anime in the scale of 1 to 10?
(Example: total reviews 199.
total reviews scored with 1 50 people
total reviews scored with NUMBERS...)

I basically want this https://myanimelist.net/topanime.php?_location=mal_h_m
but a variation with average review scores instead
Jun 19, 2020 9:08 AM

Offline
Dec 2019
3519
Korishi said:
hacker09 said:


So actually you didn't want the average scores of the reviews, you just want to know specifically the total number of reviews and the total number of people that scored the anime in the scale of 1 to 10?
(Example: total reviews 199.
total reviews scored with 1 50 people
total reviews scored with NUMBERS...)

I basically want this https://myanimelist.net/topanime.php?_location=mal_h_m
but a variation with average review scores instead


Got it.Even if was possible to do that with a JS/API the update would take a really long time to finish and would make a lot of network requests to MAL in every update and probably would take a some GBs of your hdd too,because that would be like downloading the whole MAL DB to your pc. I'ts better to sit and wait to see if one day MAL will have that feature.

For now that JS can do really fast what you want for 1 specific anime at a time, and without generating lots of network requests to MAL.
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 19, 2020 9:40 AM
Offline
Jul 2018
561874
hacker09 said:
Korishi said:

I basically want this https://myanimelist.net/topanime.php?_location=mal_h_m
but a variation with average review scores instead


Got it.Even if was possible to do that with a JS/API the update would take a really long time to finish and would make a lot of network requests to MAL in every update and probably would take a some GBs of your hdd too,because that would be like downloading the whole MAL DB to your pc. I'ts better to sit and wait to see if one day MAL will have that feature.

For now that JS can do really fast what you want for 1 specific anime at a time, and without generating lots of network requests to MAL.

GBs for text?? the db is not that large. and the network requests is what I tried explaining to you the other day but you assured me it would not be significant enough to cause concern.

the aforementioned JS is fine for now. serves its purpose.
Jun 19, 2020 10:12 AM

Offline
Dec 2019
3519
Korishi said:
hacker09 said:


Got it.Even if was possible to do that with a JS/API the update would take a really long time to finish and would make a lot of network requests to MAL in every update and probably would take a some GBs of your hdd too,because that would be like downloading the whole MAL DB to your pc. I'ts better to sit and wait to see if one day MAL will have that feature.

For now that JS can do really fast what you want for 1 specific anime at a time, and without generating lots of network requests to MAL.

GBs for text?? the db is not that large. and the network requests is what I tried explaining to you the other day but you assured me it would not be significant enough to cause concern.

the aforementioned JS is fine for now. serves its purpose.


I've no idea how heavy is MAL DB now,MAL DB also includes stuff that you won't need and won't scrape, but I also have no idea if all the numbers for all reviews,the titles of every single anime on MAL and the average score Number result would take only 1GB of disk space or much more (or less).

I didn't understand what you really wanted. I though that you just wanted to scrape all the reviews and calculate the average rating of all the reviews for 1 specific anime.Then you would aggregate these scores into a ranking list
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 19, 2020 10:28 AM

Offline
May 2018
1814
@Rob7

Here you go:



// ==UserScript==
// @name Summary Stats in %
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Summary Stats in %
// @author Me
// @include /^https:\/\/myanimelist\.net\/(anime|manga)\/[\d]+\/.*\/stats/
// @run-at document-end
// ==/UserScript==

const [,,,watching,completed,onHold,dropped,planToWatch,total] = document.querySelectorAll("#content > table > tbody > tr > td:nth-child(2) > div.js-scrollfix-bottom-rel > div");
const totalValue = getValue(total);

[watching,completed,onHold,dropped,planToWatch].forEach(addPercentage);

function getValue(node) {
const text = node.querySelector("span");
return parseInt(text.nextSibling.textContent.replace(/,/g,""));

}

function getPercentage(node) {
if(totalValue === 0) return "0.00";
const value = getValue(node);
return (value*100/totalValue).toFixed(2);
}

function addPercentage(node) {
const text = node.querySelector("span");
const valueNode = text.nextSibling;
const percentage = getPercentage(node);
valueNode.textContent = `${valueNode.textContent} (${percentage}%)`;
}
Only_BradJun 27, 2020 12:00 PM
Jun 19, 2020 12:36 PM

Offline
Dec 2019
3519
@Only_Brad

Great thank you so much again!
hacker09Jun 29, 2020 8:14 PM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 19, 2020 12:42 PM

Offline
Dec 2019
3519
@epsilon4 @yaruka

I've changed (and commented) the codes for the script to show MAL Percentages + Day or Hours, now you can see your total watched time in days or hours .

Here's how it works:

On your (or someone's) profile click anywhere on the text Days: 999, you can also click anywhere on the days numbers and then the script will convert the Days to Hours.
To show the days back again just click anywhere on the stats graph BAR.

Actually I wanted to show both at the same time,like Days:99 Hours: 2839.But I didn't want to bug Only_Brad so I learned how to show both at the "same time" in my own way.
If you guys want me to change the code again and do something like this little modification I did,just quote me here. (something that I probably can do is a "timer" that will change from days/hours in a loop and calculate days to minutes).

https://pastebin.com/QLafZ8TK


The codes on https://pastebin.com/XYEcqppS shows both days and hours at the same time. (This link already includes the scripts commented below by Only_Brad)
hacker09Jun 29, 2020 8:05 PM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 19, 2020 11:24 PM

Offline
May 2018
1814
@hacker09

if you want to show both Hours and Days, in my original code, replace:

GM_addStyle(".profile .user-statistics .stats-status{width: 200px;}");
const time = document.querySelector(".di-tc.al.pl8.fs12.fw-b"),
         timeType = time.querySelector("span"),
         timeValueNode = timeType.nextSibling,
         timeValue = parseFloat(timeValueNode.textContent);

timeType.textContent = "Hours: ";
timeValueNode.textContent = (timeValue * 24).toFixed(1);


with

    GM_addStyle(".profile .user-statistics .stats-status{width: 200px;}");
    const days = document.querySelector(".di-tc.al.pl8.fs12.fw-b"),
              hours = days.cloneNode(true),
              hoursText = hours.querySelector("span"),
              hoursValueNode = hoursText.nextSibling,
              hoursValue = parseFloat(hoursValueNode.textContent);

    hoursText.textContent = "Hours: ";
    hoursValueNode.textContent = (hoursValue * 24).toFixed(1);
    days.insertAdjacentElement("afterend",hours);


Only_BradJun 19, 2020 11:28 PM
Jun 20, 2020 8:35 AM

Offline
Dec 2019
3519
@Only_Brad

Thanks.

Could you make a script that shows the estimated time of how many hours will be need to complete an anime?
(This case 35*8)


I also tried to use https://greasyfork.org/en/scripts/370335-myanimelist-advanced-bbcode-editor/code
But even though I wrote a lot of things I always get a error message saying that "Your message must contain a text". I read the source code but I didn't really know what's the problem. This is a old script and the Dev stopped working on it.
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 20, 2020 5:51 PM

Offline
May 2018
1814
@hacker09

Here you go.



// ==UserScript==
// @name         Total duration
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Total duration
// @author       Me
// @include      /^https:\/\/myanimelist\.net\/anime\/[\d]+(\/.*)?/
// @run-at document-end
// ==/UserScript==

(function(){
    let totalEps = document.getElementById("curEps").textContent;
    if(totalEps === "?" || totalEps === "1") return;
    totalEps = parseInt(totalEps);

    const informationHeader = findInformation(),
          durationNode = findDuration(),
          durationText = durationNode.querySelector("span"),
          durationValueNode = durationText.nextSibling,
          durationValue = durationValueNode.textContent.trim();

    const epDuration = extractDuration();
    const totalDurationNode = durationNode.cloneNode(true);
    const remainingTimeNode = durationNode.cloneNode(true);

    showTotalDuration();
    showRemainingDuration();

    function findInformation() {
        const headers = [...document.querySelectorAll("h2")];
        return headers.find(h2 => h2.textContent === "Information");
    }

    function findDuration() {
        const allInfo = [...informationHeader.parentNode.querySelectorAll("div")];
        return allInfo.find(info => info.innerText.includes("Duration"));
    }

    function extractDuration() {
        const DURATION_REGEX = /(?:(\d+) hr\. )?(\d+) min\./
        const match = durationValue.match(DURATION_REGEX);
        let hours,mins;

        if(match) [,hours,mins] = match;
        else hours = mins = 0;
        if(!hours) hours = 0;
        if(!mins) mins = 0;

        return {
            hours: parseInt(hours),
            mins: parseInt(mins)
        }
    }

    function getTotalDuration(epCount,{hours,mins}) {
        const
            totalMinutes = mins + hours*60,
            totalDuration = epCount * totalMinutes,
            totalDurationHours = Math.floor(totalDuration / 60),
            totalDurationMins = totalDuration % 60;

        return {
            hours: totalDurationHours,
            mins: totalDurationMins
        }
    }

    function showDuration({epCount,durationNode,siblingNode,text}) {
        const {hours,mins} = getTotalDuration(epCount,epDuration);
        const durationText = durationNode.querySelector("span");
        const durationValue = durationText.nextSibling;
            
        durationText.textContent = text
        durationValue.textContent = ` ${hours?hours+" hr." : ""} ${mins?mins+" min." : ""}`;
        siblingNode.insertAdjacentElement("afterend",durationNode);
    }

    function showTotalDuration() {
        showDuration({
            epCount: totalEps,
            durationNode: totalDurationNode,
            siblingNode: durationNode,
            text: "Total Duration:"
        });
    }

    function showRemainingDuration() {
        let epWatched = document.getElementById("myinfo_watchedeps");
        if(isNaN(epWatched.value)) return;

        epWatched = parseInt(epWatched.value);
        const epRemaining = totalEps - epWatched;
        showDuration({
            epCount: epRemaining,
            durationNode: remainingTimeNode,
            siblingNode: totalDurationNode,
            text: "Remaining time:"
        });
    }
})()
Only_BradJun 29, 2020 9:28 PM
Jun 20, 2020 5:53 PM

Offline
Dec 2019
3519
@Only_Brad
Thank you so much again.
Now MAL became a really better website
hacker09Jun 20, 2020 5:58 PM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 20, 2020 6:00 PM

Offline
May 2018
1814
hacker09 said:
@Only_Brad
Thank you so much again.
Now MAL became a really better website


There was an error (I updated the code)

the line with // @include should be this:

// @include /^https:\/\/myanimelist\.net\/anime\/[\d]+\/.*

for some some reason the forum removed the backslashes. It ruined the regular expression in the extractDuration function too.
Only_BradJun 20, 2020 6:13 PM
Jun 20, 2020 6:25 PM

Offline
Dec 2019
3519
@Only_Brad
lol.Thanks again.

But that didn't work.

The line // @exclude *://myanimelist.net/forum* needs to be changed to include to work on the forum and without that line the script doesn't run on the forum pages,I tried to change that line with your code,and I erased all lines with include and exclude and just added your code but this didn't work too.

The whole scripts has lots of lines with // @include

The line // @include /^https:\/\/myanimelist\.net\/forum\/[\d]+\/.* doesn't work and doesn't run, but without \/[\d]+\/.* the script is run but the bug still happening

Doing the same changes on the line // @include *://myanimelist.net/comments* also runs the script, even with \/[\d]+\/.* But with the same past problem,so the bug probably happens on all the other lines too so I didn't try to change the other lines yet
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 20, 2020 7:04 PM

Offline
May 2018
1814
@hacker09

I don't think you are using the right code, I don't have any @excludes in the one I posted previously and there is only 1 @include
Jun 20, 2020 7:16 PM

Offline
Dec 2019
3519
@Only_Brad
Wich of the scripts are you talking about?

Oh, I think that I got it. You are saying that I should change that line on the script you just made to calculate the total time to watch the anime right?
If that's the case, I'm using your old code and it's working perfectly...

I can't see any differences on the line // @include comparing your old and new // @include
Maybe when I copied your total time script you already changed it (edited your post)? I'm not sure

You made the script like what,6 hours ago? and the forum changed something in this small time? MAL never does any changes or update the html/js I think

To make sure eveything is okay I just copied your last script again to tampermonkey
The only error on your last total time script according to tampermonkey is that "Parsing eror: Unexpected token totalEps"

Now,because of all these scripts, I hope that mal never update or change anything on their html/js
hacker09Jun 20, 2020 7:30 PM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 21, 2020 8:41 AM

Offline
Dec 2019
3519
@Only_Brad
Can the script do a subtraction calculation too? Like if the total anime duration takes 4 hours with 10 eps,when I watch 5 eps I will have 2hrs left to complete the anime. That would be good for big animes.
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 22, 2020 9:34 AM

Offline
May 2018
1814
hacker09 said:
@Only_Brad
Can the script do a subtraction calculation too? Like if the total anime duration takes 4 hours with 10 eps,when I watch 5 eps I will have 2hrs left to complete the anime. That would be good for big animes.


I've modified my previous code, it should show the remaining time.

Jun 22, 2020 9:46 AM

Offline
Dec 2019
3519
@Only_Brad
Thank you so much again,these scripts are so NICE! MAL really does need to implement as fast as possible all of your scripts.
Something that I still can't believe in, is that MAL does offer a tab called episodes so users can watch the animes on crunchyroll, but the episodes are not automatically tracked on the Details tab.

I've seen lots of scripts online saying that they can track on MAL all the animes and also the episodes you are watching on crunchyroll or kissanime etc, but I don't think that they also work for the Episodes tab on MAL.I will probably try out a few of these scripts to see if they also can keep track of the Episodes tab on MAL.
hacker09Jun 22, 2020 9:51 AM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 22, 2020 11:19 AM
Offline
Jul 2018
561874
@hacker09 the scripts are awesome, but if you think about it, it's just more features that the devs need maintain.
I advocate for a set of built-in customisable features for each user to creatively set for himself for his own viewing, but likely QoL improvements will be low priority until deemed necessary.
Jun 22, 2020 11:50 AM

Offline
Dec 2019
3519
@Korishi
If by devs you mean the MAL devs, I already agree with you when I said "MAL really does need to implement as fast as possible all of your scripts."

It's sad that Only_Brad and other devs not paid by MAL need to make the features and also keep updating the feature they've made.They could be watching more animes, but because they are kind they made and shared their codes/knowledge with everyone.

Mal totally doesn't care about QoL improvements,they don't even care about updating just the website "CSS".so the website would look like a website from 2020 hahaha.

I tried to use kissanime something greasyfork script but it's old and not updated anymore,they recommend the malsync script.I talked with the malsync devs and they said that their scripts can't track embedded websites/animes. So the MAL tab Episodes and not tracked.They don't want to add this feature either ¬¬.
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 22, 2020 5:35 PM

Offline
Dec 2019
3519
@Only_Brad

I'm trying to make a new script that will help me and others to know if there's any existent live-actions or doramas for any entries on mal.
The script is working perfectly, but the script only opens 1 page.

I'm quoting you because I actually want to have only 1 button, and when I click on that button 4/5 pages will open instead of only 1.
I also tried to make a button to click and copy the Anime Title to the clipboard, but without success.

I tried to ask the malsync script dev to add this option to their script,but they also didn't really seem to be willing to do this,so I did it myself.
Here is the script
https://greasyfork.org/en/scripts/407727-search-for-live-actions-doramas-all-related-entries-correct-watch-order-copy-entry-title
I've updated the script and now,there's a button that can find all the related MAL entries for any anime and also show the correct watch order for any anime on MAL!

hacker09Jul 25, 2020 2:36 PM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 22, 2020 6:40 PM

Offline
May 2018
1814
hacker09 said:
@Only_Brad

I'm trying to make a new script that will help me and others to know if there's any existent live-actions or doramas for any entries on mal.
The script is working perfectly, but the script only opens 1 page.

I'm quoting you because I actually want to have only 1 button, and when I click on that button 4/5 pages will open instead of only 1.
I also tried to make a button to click and copy the Anime Title to the clipboard, but without success.

I tried to ask the malsync script dev to add this option to their script,but they also didn't really seem to be willing to do this,so I'm doing it myself.

https://pastebin.com/BwVm2tzh



that's because your button only sends you to 1 url

findButton.setAttribute("href", "https://www.imdb.com/find?q=" + title);

We can't scrap IMDB data on MAL's domain, it's blocked by the browser's CORS policy. (To see if you can scrap a website with a different domain tham the one you currently on, enter the developer's console by pressing F12, go to the console tab then type
fetch("https://www.imdb.com/find?q=naruto");
while you are on www.myanimelist.net. It should give you this error


Access to fetch at 'https://www.imdb.com/find?q=naruto' from origin 'https://myanimelist.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.


The solution for this is to:

Scrap using a proxy server (not a good long term solution, we have no idea how long this server will run)
Making your own proxy server (you'll need to make your own server, not very practical)
Using an API

IMDB doesn't have an official API, you'd have to use 3rd party ones. Most of them have paid API KEYS.

I fouind one that allows 1000 request per day for free, it should more than enough.

http://www.omdbapi.com/apikey.aspx?__EVENTTARGET=freeAcct&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=%2FwEPDwUKLTIwNDY4MTIzNQ9kFgYCAQ9kFgICBw8WAh4HVmlzaWJsZWhkAgIPFgIfAGhkAgMPFgIfAGhkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYDBQtwYXRyZW9uQWNjdAUIZnJlZUFjY3QFCGZyZWVBY2N0x0euvR%2FzVv1jLU3mGetH4R3kWtYKWACCaYcfoP1IY8g%3D&__VIEWSTATEGENERATOR=5E550F58&__EVENTVALIDATION=%2FwEdAAU5GG7XylwYou%2BzznFv7FbZmSzhXfnlWWVdWIamVouVTzfZJuQDpLVS6HZFWq5fYpioiDjxFjSdCQfbG0SWduXFd8BcWGH1ot0k0SO7CfuulN6vYN8IikxxqwtGWTciOwQ4e4xie4N992dlfbpyqd1D&at=freeAcct&Email=

Using their API is simple

all you have to do is an XHR or fetch with this url: http://www.omdbapi.com/?apikey=[yourkey]&s=naruto

It will send back a JSON file (I haven't checked that yet, but that's what 99% of API will send back nowadays)

the JSON file will most likely contains the URL we need.
Jun 22, 2020 6:47 PM

Offline
Dec 2019
3519
@Only_Brad

Thanks for all your help.
Actually I'm not planning on anything like fetching something or using APIs...

I just want to know how can I make a Copy button for the anime title.

And I want to do something like this

findButton.setAttribute("href", "https://www.imdb.com/find?q=" + title + "https://www.anothersite.com/find?q=" + title);
OR
findButton.setAttribute("href", "https://www.imdb.com/find?q=" + title, "href", "https://www.imdb.com/find?q=" + title);

Both of them doesn't work anyways.

Actually the script works perfectly with imdb by opening the imdb website in a new tab and searching the anime name, this url works perfectly for example https://www.imdb.com/find?q=naruto

I just want a copy anime title button and know how can I open more browser tabs instead of opening only 1 tab.

If you open this
https://html.house/5pyd9khy.html you will understand what I want,the problem is that I need to use the tampermonkey, because then I don't need to manually copy and paste the anime name every time to all these websites.

Not just a copy button and opening more tabs would be nice, but also a code that opens the MAL Club link and automatically presses CTRL+F and paste the anime title would be way nice too if possible,but this is not the most important I think.

I want only 1 unique button to do this https://html.house/5pyd9khy.html and another button just to copy the anime title
hacker09Jun 22, 2020 6:53 PM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 22, 2020 6:56 PM

Offline
May 2018
1814
@hacker09

this is the code they are using on the html.house link you sent

    
    window.open('https://www.imdb.com/', '_blank');
    window.open('http://asianwiki.com/', '_blank');
    window.open('https://mydramalist.com/', '_blank');
    window.open('https://myanimelist.net/clubs.php?cid=5450', '_blank')


so I would replace

findButton.setAttribute("target", "_blank");
findButton.setAttribute("href", "https://www.imdb.com/find?q=" + title);


with

findButton.addEventListener("click",()=>{
    window.open("https://www.imdb.com/find?q="+title, "_blank");
    window.open("http://asianwiki.com/index.php?title=Special%3ASearch&search="+title, "_blank");
    window.open("https://mydramalist.com/search?q="+title, "_blank");
    window.open("https://myanimelist.net/clubs.php?cid=5450", "_blank");
});


to copy the title in the clipboard then open the 4 links, try this:

findButton.addEventListener("click",()=>{
    navigator.clipboard.writeText(title).then(()=>{
        window.open("https://www.imdb.com/find?q="+title, "_blank");
        window.open("http://asianwiki.com/index.php?title=Special%3ASearch&search="+title, "_blank");
        window.open("https://mydramalist.com/search?q="+title, "_blank");
        window.open("https://myanimelist.net/clubs.php?cid=5450", "_blank");
    });
});

Only_BradJun 22, 2020 7:12 PM
Jun 22, 2020 8:41 PM

Offline
Dec 2019
3519
@Only_Brad

Thank you so much. I'm the one that made that html.house link.

I've finished The TamperMonkey Script "Search for Live-Actions\Doramas + All Related Entries + Correct Watch Order + Copy Entry Title" https://greasyfork.org/en/scripts/407727-search-for-live-actions-doramas-all-related-entries-correct-watch-order-copy-entry-title/
I've updated the script and now,there's a button that can find all related MAL entries for any animes, and also show the correct watch order for any animes on MAL!



Another tampermonkey script that I did
https://myanimelist.net/forum/?topicid=1846937&show=50#msg60108198
hacker09Jul 25, 2020 3:44 PM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 25, 2020 9:41 PM

Offline
May 2018
1814
@hacker09 @epsilon4 @yaruka @Rob7

I've modified one line of code in the "Days to Hours" script

the line

timeValue = parseFloat(timeValueNode.textContent);


should be replaced with

timeValue = parseFloat(timeValueNode.textContent.replace(/,/g,""));


This will fix errors with Days => Hour when Days > 999.
Example of a profile with Days > 999:
https://myanimelist.net/profile/DateYutaka
Only_BradJun 27, 2020 12:06 PM
Jun 26, 2020 7:06 AM

Offline
Dec 2019
3519
@Only_Brad
Thank you again.
1 My new ideas to do are to make a button like the copy button I did, but close to the EDIT button,this button would redirect me to the edit duration page (of animes).
I was able to do my 1 idea, here's the Script https://myanimelist.net/forum/?topicid=1846937&show=50#msg60108198

2 Another thing I will try to do is to automatically ADD the the finished and started days when the anime is marked as watching/completed.(if this is hard to do I will try to show below the anime image a button to add the dates).I will probably analyse and modify https://greasyfork.org/en/scripts/26869-myanimelist-add-friends-statistics-to-main-page to do that.
I will probably need to add an event listener to the complete and watching words,when they are choosen the pc dates will be automatically added,and when plan to watch is selected all the dates will be erased (or I will add a button to erase them).I was thinking about it last night and even if I can do this, I will still want to the see the dates below the anime image,so that I can confirm that the script worked,so I will need to do something like this https://greasyfork.org/en/scripts/26869-myanimelist-add-friends-statistics-to-main-page anyways.
I was able to do something a little bit similar to this, and is helpful https://myanimelist.net/forum/?topicid=1846937&show=50#msg60125424

3 Another thing I want to try to do is to modify all anime page entries to show the anime duration time with seconds by default when the page is loaded.

I'm not sure but maybe I will ask for your help
hacker09Aug 1, 2020 12:50 PM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 26, 2020 6:52 PM

Offline
May 2018
1814
hacker09 said:
@Only_Brad
Another thing I will try to do is to automatically ADD the the finished and started days when the anime is marked as watching/completed.(if this is hard to do I will try to show below the anime image a button to add the dates).I will probably analyse and modify https://greasyfork.org/en/scripts/26869-myanimelist-add-friends-statistics-to-main-page to do that


It shouldn't be hard. You need to add a "change" event listener on the "Complete/Watching/Dropped/etc" selection box. If the value selected is "Complete" then you grab the total episode count, get its value, then store it in the last episode watched input. I'll probably write the code later if I'm not lazy lol.
Jun 27, 2020 4:06 AM

Offline
Dec 2019
3519
Only_Brad said:
hacker09 said:
@Only_Brad
Another thing I will try to do is to automatically ADD the the finished and started days when the anime is marked as watching/completed.(if this is hard to do I will try to show below the anime image a button to add the dates).I will probably analyse and modify https://greasyfork.org/en/scripts/26869-myanimelist-add-friends-statistics-to-main-page to do that


It shouldn't be hard. You need to add a "change" event listener on the "Complete/Watching/Dropped/etc" selection box. If the value selected is "Complete" then you grab the total episode count, get its value, then store it in the last episode watched input. I'll probably write the code later if I'm not lazy lol.


I don't think that I will need to grab the total episode count, get its value, then store it in the last episode watched input. But I will probably add and event listener to complete and watching words,when they are choosen the pc dates will be automatically added,and when plan to watch is selected all the dates will be erased (or I will add a button to erase them).I was thinking about it last night and even if I can do this, I will still want to the see the dates below the anime image,so that I can confirm that the script worked,so I will need to do something like this https://greasyfork.org/en/scripts/26869-myanimelist-add-friends-statistics-to-main-page anyways.
I'm busy these days so I will probably start figuring out how to do all of these things in a few days.
I guess that MalSync script has something like it in their scripts,but their script has 3.000+ lines of codes,I'm probably not willing to analyse all that codes just to find what codes are the one's that might help me doing that Dates Feature that I want to do.
hacker09Jun 27, 2020 4:49 AM
Click here to see My Tampermonkey Scripts For MAL

If you like my work, please consider supporting it!
Cryptos / Patreon / Ko-Fi / BuyMeaCoffee https://cyber-sec0.github.io
Jun 27, 2020 11:01 AM

Offline
May 2019
3444
Only_Brad said:


I've modified one line of code in the "Days to Hours" script

the line

timeValue = parseFloat(timeValueNode.textContent);


should be replaced with

timeValue = parseFloat(timeValueNode.textContent.replace(",",""));


This will fix errors with Days => Hour when Days > 999.
Example of a profile with Days > 999:
https://myanimelist.net/profile/DateYutaka



Thanks!

But i perceived similar error at the % for the stats:



How to fix it?
Jun 27, 2020 12:04 PM

Offline
May 2018
1814
@Rob7 @hacker09

I've edited the code: https://myanimelist.net/forum/?topicid=1846937&show=0#msg60043733

replace

function getValue(node) {
const text = node.querySelector("span");
return parseInt(text.nextSibling.textContent.replace(",",""));
}


with

function getValue(node) {
const text = node.querySelector("span");
return parseInt(text.nextSibling.textContent.replace(/,/g,""));
}


in fact, I suggest replacing all

replace(",",""));


with

replace(/,/g,""));


I'm gonna edit all the codes in this thread to have this change. The problem is that replace(",","") will only find the first comma and remove it whereas replace(/,/g,"") will find all of them then remove them.
Only_BradJun 27, 2020 12:11 PM
Pages (2) [1] 2 »

More topics from this board

» What are you playing right now? (v2) ( 1 2 3 4 5 ... Last Page )

anime-prime - Oct 4, 2020

4080 by Yuri-Crusader »»
3 hours ago

Poll: » Fire Emblem: Fortune's Weave announced

wildhood - Sep 12

7 by Geark77 »»
4 hours ago

» Japanese/Foreign Video Games: Sub or Dub?

FuunsaikiStar - 7 hours ago

4 by Zarutaku »»
5 hours ago

Poll: » The Super Mario Galaxy Movie announced

wildhood - Sep 12

10 by FuunsaikiStar »»
7 hours ago

» For people that are so ignorant to understand Velvet's character, read this! (beat Berseria first))

SOT_Daemon - Yesterday

3 by Shishio-kun »»
9 hours ago
It’s time to ditch the text file.
Keep track of your anime easily by creating your own list.
Sign Up Login