Youtube履歴ページで指定したチャンネルの動画を表示

// ==UserScript==
// @name         youtube_history_abema
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.youtube.com/feed/history
// @grant        none
// ==/UserScript==
var result2 = document.evaluate('//input[@id="search"]', document, null, 7, null);
result2.snapshotItem(0).addEventListener('change', function () {
  if (result2.snapshotItem(0).value == "acc") {
    var sign = window.prompt("検索するチャンネル名を入力してください", "AbemaTV");
    var reg = new RegExp(sign);
    var result = document.evaluate('//ytd-video-renderer[.//yt-formatted-string[@id="byline"]]', document, null, 7, null);
    var result4 = document.evaluate('//ytd-video-renderer//yt-formatted-string[@id="byline"]', document, null, 7, null);
    for (var i = 0; i < result.snapshotLength; i++) {
      if (reg.test(result4.snapshotItem(i).title)) {
        result.snapshotItem(i).classList.add("kore");
      }
    }
    var result3 = document.evaluate('//ytd-video-renderer[not(contains(@class,"kore"))]', document, null, 7, null);
    for (var j = 0; j < result3.snapshotLength; j++) {
      result3.snapshotItem(j).style.display = 'none';
    }
  } else if (result2.snapshotItem(0).value == "copy") {
    var result5 = document.evaluate('//ytd-video-renderer[contains(@class,"kore")]//a[@id="video-title"]', document, null, 7, null);
    var buf = "";
    for (var k = 0; k < result5.snapshotLength; k++) {
      buf = buf + " " + result5.snapshotItem(k).href;
    }
    var sign2 = window.prompt("url_list", buf);
  }
});