Export Your Anime/Manga XML List On Any Page + Wayback Machine Your Profile.

This script adds a button on any anime/manga page, click on this button to download your Anime/Manga XML list. There's a button that's added on your profile only and Backups Your Profile using the Wayback Machine services.

Tính đến 23-11-2020. Xem phiên bản mới nhất.

// ==UserScript==
// @name         Export Your Anime/Manga XML List On Any Page + Wayback Machine Your Profile.
// @namespace    http://tampermonkey.net/
// @version      0.8
// @description  This script adds a button on any anime/manga page, click on this button to download your Anime/Manga XML list. There's a button that's added on your profile only and Backups Your Profile using the Wayback Machine services.
// @author       hacker09
// @include      /^https:\/\/myanimelist\.net\/anime\/[\d]+(\/.*)?/
// @include      /^https:\/\/myanimelist\.net\/manga\/[\d]+(\/.*)?/
// @match        https://myanimelist.net/profile/*
// @match        https://myanimelist.net/panel.php?go=export
// @require      https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';
    var $ = window.jQuery; //Defines That The Symbol $ Is A jQuery
    var username = document.querySelector('a.header-profile-link').innerText;

    if (location.href === 'https://myanimelist.net/panel.php?go=export')
    {
      document.querySelector("input.inputButton").outerHTML = '<input type="submit" name="subexport" value="Export My List Now" class="inputButton">';
    }
    //*****************************************************************************************************************************************************
    if (location.href !== 'https://myanimelist.net/panel.php?go=export' && window.location.href !== 'https://myanimelist.net/profile/'+username+'')
     {
    var type,downtype;
    var token = document.head.querySelector("[name='csrf_token']").content;

    window.location.pathname.split('/')[1] === 'anime' ? (type = 'anime', downtype = 'type=1') : (type = 'manga', downtype = 'type=2');
    var XMLBackupBTN = document.createElement("a");
    type === 'anime' ? XMLBackupBTN.innerHTML = "Backup My AnimeList" : XMLBackupBTN.innerHTML = "Backup My MangaList";
    document.querySelector("span.information.type").parentElement.appendChild(XMLBackupBTN);
    XMLBackupBTN.setAttribute("id", "XMLBackupBTN");
    XMLBackupBTN.setAttribute("style", "cursor: pointer;margin-left: 15px;font-size: 10px;");
     document.querySelector("#XMLBackupBTN").addEventListener ("click", function() {(async function() {
    const response = await fetch("https://myanimelist.net/panel.php?go=export", { "headers": { "content-type": "application/x-www-form-urlencoded"}, "body": downtype+"&subexport=Export+My+List&csrf_token="+token+"", "method": "POST"}); //Get the xml file
    const html = await response.text(); //Gets the fetch response
    const newDocument = new DOMParser().parseFromString(html, 'text/html'); //Parses the fetch response
    document.location = newDocument.querySelectorAll("div.goodresult")[0].childNodes[2].href;
}()); //Finishes the async function
} , false);
}
    //*****************************************************************************************************************************************************
    if (window.location.href === 'https://myanimelist.net/profile/'+username+'')
{
    var BackupProfileBTN = document.createElement("a");
    BackupProfileBTN.innerHTML = "Backup My Profile";
    document.querySelector("a.header-right.mt4.mr0").parentElement.appendChild(BackupProfileBTN);
    BackupProfileBTN.setAttribute("id", "BackupProfileBTN");
    BackupProfileBTN.setAttribute("style", "cursor: pointer;margin-left: 15px;font-size: 10px;");
    document.querySelector("#BackupProfileBTN").addEventListener ("click", saveprofileonarchiveorg , false);
    function saveprofileonarchiveorg (){function iFrameLoaded(id, src) {
    var deferred = $.Deferred(),
        iframe = $("<iframe id='iframe'></iframe>").attr({
            "id": id,
            "src": src
        });

    iframe.load(deferred.resolve);
    iframe.appendTo("body");

    deferred.done(function() {
        console.log("iframe loaded: " + id);
    });

    return deferred.promise();
}
$.when(iFrameLoaded("Update MALGraph", "https://anime.plus/"+username+"/queue-add"),
iFrameLoaded("Update Badges", "https://www.mal-badges.net/users/"+username+"/update"),
iFrameLoaded("Currently Watching", "https://web.archive.org/save/https://myanimelist.net/animelist/"+username+"?status=1"),
iFrameLoaded("Completed", "https://web.archive.org/save/https://myanimelist.net/animelist/"+username+"?status=2"),
iFrameLoaded("On Hold", "https://web.archive.org/save/https://myanimelist.net/animelist/"+username+"?status=3"),
iFrameLoaded("Dropped", "https://web.archive.org/save/https://myanimelist.net/animelist/"+username+"?status=4"),
iFrameLoaded("Plan to Watch", "https://web.archive.org/save/https://myanimelist.net/animelist/"+username+"?status=6"),
iFrameLoaded("Topics in Forum Replied To", "https://web.archive.org/save/https://myanimelist.net/forum/search?u="+username+"&q=&uloc=1&loc=-1"),
iFrameLoaded("MAL History", "https://web.archive.org/save/https://myanimelist.net/history/"+username+"/anime"),
iFrameLoaded("Profile texts/statistics/Favorites/Comments and 12 Friends","https://web.archive.org/save/https://myanimelist.net/profile/"+username+"#statistics"), iFrameLoaded("Clubs","https://web.archive.org/save/https://myanimelist.net/profile/"+username+"/clubs"),
iFrameLoaded("Recommendations", "https://web.archive.org/save/https://myanimelist.net/profile/"+username+"/recommendations"),
iFrameLoaded("Reviews", "https://web.archive.org/save/https://myanimelist.net/profile/"+username+"/reviews"))
.then(function() {window.location.assign("https://google.com");
});
}}
})();