Search Openings/Endings on Youtube - MAL

Click on the opening/ending music title to search for the music title on youtube on a new tab.

目前为 2021-06-03 提交的版本。查看 最新版本

// ==UserScript==
// @name        Search Openings/Endings on Youtube - MAL
// @namespace   Search_Ops_Ends
// @version     0.2
// @description Click on the opening/ending music title to search for the music title on youtube on a new tab.
// @author      hacker09
// @match       https://myanimelist.net/anime/*
// @match       https://myanimelist.net/manga/*
// @icon        https://www.google.com/s2/favicons?domain=myanimelist.net
// @run-at      document-end
// ==/UserScript==

(function() {
  'use strict';
  if (document.querySelectorAll('span[class*="theme-song"]').length !== 0) //If there's at least one op/end listed on the page
  { //Starts the if condition
    document.querySelectorAll('span[class*="theme-song"]').forEach(function(el) { //For each op/end
      var title = el.innerText.split(': ')[1].split('(ep')[0].trim(); //Save the op/end title on a variable

      el.style.cursor = 'pointer'; //Make the op/end title element look like it's clickable

      el.onclick = function() //When the op/end title is clicked
      { //Starts the onclick function
        window.open('https://www.youtube.com/results?search_query=' + title, 'blank'); //Search the music title on youtube on a new tab
      }; //Finishes the onclick function

    }); //Finishes the for each condition
  } //Finishes the if condition
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址