Ya YouTube search

Поиск видео в YouTube со страницы Яндекса.

当前为 2023-10-27 提交的版本,查看 最新版本

// ==UserScript==
// @name         Ya YouTube search
// @name:en      Ya YouTube search
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Поиск видео в YouTube со страницы Яндекса.
// @description:en  Search videos on YouTube from Yandex page.
// @author       E11ipS0iD
// @match        https://yandex.ru/*
// @match        https://ya.ru/*
// @icon         https://www.ellipse-arts.ru/temp/fav.jpg
// @license      MIT
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

    setTimeout(function(){testPlayerData();}, 1000);

    function testPlayerData() {

        var btn = document.querySelectorAll('.HeaderDesktopNavigation-Cutted .HeaderDesktopNavigation-Tab')[2];
        if (btn!==undefined) {
            btn.id = 'ytFromYa';
            btn.innerHTML = 'YouTube';
            var link = document.querySelectorAll('.HeaderDesktopForm-Input')[0].value;
            link = encodeURI(link);
            btn.href = 'https://www.youtube.com/results?search_query=' + link;
            console.log('YouTube link updated');
            return true;
        }

        var video = document.getElementsByClassName("VideoPlayerMetaInfo-SourceTextLine")[0];
        if (video!==undefined && video.innerHTML == '<b>YouTube</b>') {
            console.log('YouTube player - founded');
            document.location.replace(document.getElementsByClassName("LinkWrapper")[0].href);
            return true;
        }
        setTimeout(function(){testPlayerData();}, 1000);
    }

})();

QingJ © 2025

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