My Anime List Open Every Anime in the search page

<The button is located in the dropdown menu> This script opens all anime links from MyAnimeList's Search page. It doesn't give you sequels (if they have similar names AND are on the same page).

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         My Anime List Open Every Anime in the search page
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  <The button is located in the dropdown menu> This script opens all anime links from MyAnimeList's Search page. It doesn't give you sequels (if they have similar names AND are on the same page).
// @author       TheBerzzeker
// @match        *://myanimelist.net/anime.php*
// @grant        GM.xmlHttpRequest
// ==/UserScript==


var animeNames = [];

var animeLinks = [];

function initialize(){

    createUI();
    getAnime();

}

function createUI(){

    var dropdown = document.getElementsByClassName("header-menu-dropdown header-profile-dropdown arrow_box")[0].childNodes[0];

    var button = dropdown.childNodes[0].cloneNode(true);

    console.log(button.innerHTML);

    button.innerHTML = "<a>Open All Anime Links</a>";
    button.addEventListener ("click", openAllLinks, false);

    dropdown.appendChild(button);



}

function getAnime(){

    var list = document.getElementsByClassName("js-categories-seasonal js-block-list list")[0].firstElementChild.firstElementChild.childNodes;

    for(var i =1;i<list.length;++i){
        var itemList = list[i].childNodes;

        if(itemList.length === 0) continue;

        var link = itemList[1].innerHTML;

        link = link.split('href="')[1];
        link = link.split('" id')[0];

        var splitLink = link.split("/");

        var name = splitLink[splitLink.length-1];

        if(check(name)){
            animeNames.push(name);
            animeLinks.push(link);
        }

    }

}



function check(name){

    if (animeNames === null || animeNames.length===0) return true;

    for(var i = 0; i< animeNames.length;++i){
        if(name.includes(animeNames[i])) return false;
    }

    return true;


}


function openAllLinks(){


    for(var i=0;i<animeLinks.length;++i){console.log(i); popUpCheck(window.open(animeLinks[i],'_blank'));}

}


function popUpCheck(window){

    if(!window || window.closed || typeof window.closed=='undefined') alert("Please ENABLE POP-UPS for this script to work");

}







initialize();