您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
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.
当前为
// ==UserScript== // @name Export Your Anime/Manga XML List On Any Page + Wayback Machine Your Profile. // @namespace http://tampermonkey.net/ // @version 0.9 // @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; //Save the user name to a variable if (location.href === 'https://myanimelist.net/panel.php?go=export') { //If the user is on the export MAL page document.querySelector("input.inputButton").defaultValue = "Export My List Now"; //Change the export button text } //***************************************************************************************************************************************************** if (window.location.href.match(/^https:\/\/myanimelist\.net\/anime\/[\d]+(\/.*)?/) || window.location.href.match(/^https:\/\/myanimelist\.net\/manga\/[\d]+(\/.*)?/)) { //If the user is on a manga/anime page var type, downtype; //Make these variables global var token = document.head.querySelector("[name='csrf_token']").content; //Save the user csrf_token to a variable window.location.pathname.split('/')[1] === 'anime' ? (type = 'anime', downtype = 'type=1') : (type = 'manga', downtype = 'type=2'); //Set the page and download types var XMLBackupBTN = document.createElement("a"); //Creates the backup button element type === 'anime' ? XMLBackupBTN.innerHTML = "Backup My AnimeList" : XMLBackupBTN.innerHTML = "Backup My MangaList"; //Add the correct text to the button document.querySelector("span.information.type").parentElement.appendChild(XMLBackupBTN); //Add the button to the page XMLBackupBTN.setAttribute("id", "XMLBackupBTN"); //Adds an id to the button XMLBackupBTN.setAttribute("style", "cursor: pointer;margin-left: 15px;font-size: 10px;"); //Sets the css style of the button document.querySelector("#XMLBackupBTN").addEventListener("click", function() { //Add a click advent listener to the button (async function() { //Starts the async function const response = await fetch("https://myanimelist.net/panel.php?go=export", { //Fetch the export MAL page "headers": { //Adds the header to the request "content-type": "application/x-www-form-urlencoded" //Set the content type }, //Ends the fetch request headers "body": downtype + "&subexport=Export+My+List&csrf_token=" + token + "", //Define the download type "method": "POST" //Fetch as 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; //Redirect the user to the xml file }()); //Finishes the async function }, false); //Finishes the advent listener } //Finishes the if condition //***************************************************************************************************************************************************** if (window.location.href === 'https://myanimelist.net/profile/' + username + '') { //If the user is on his profile page var BackupProfileBTN = document.createElement("a"); //Creates the backup profile button element BackupProfileBTN.innerHTML = "Backup My Profile"; //Adds a text to the button document.querySelector("a.header-right.mt4.mr0").parentElement.appendChild(BackupProfileBTN); //Add the button to the page BackupProfileBTN.setAttribute("id", "BackupProfileBTN"); //Set an id to the button BackupProfileBTN.setAttribute("style", "cursor: pointer;margin-left: 15px;font-size: 10px;"); //Set the button css style document.querySelector("#BackupProfileBTN").addEventListener("click", saveprofileonarchiveorg, false); //Add a click advent listener to the button function saveprofileonarchiveorg() { //Starts the function to backup the user profile function iFrameLoaded(id, src) { //Creates a function var deferred = $.Deferred(), iframe = $("<iframe id='iframe'></iframe>").attr({ //Creates the iframe "id": id, //Sets the iframe id "src": src //Sets the iframe source }); //Finishes the attrib iframe.load(deferred.resolve); //Load the page and wait to be fully loaded iframe.appendTo("body"); //Add the iframe to the actual page body deferred.done(function() { //When the iframe finished loading console.log("iframe loaded: " + id); //Show a message on the browser console for dev purposes }); //Finishes the function return deferred.promise(); } //Finishes the IframeLoaded function $.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() { //After all iframes finished loading document.querySelector("title").innerText = 'DONE!!!_______DONE!!!'; //Change the tab title }); //Finishes the "then" function } //Finishes the saveprofileonarchiveorg function } //Finishes the if condition })();