Fitgirl [ Youtube Preview ]

adds YouTube Preview links below video game titles, easily watch video of the game before playing it

目前为 2023-06-18 提交的版本。查看 最新版本

// ==UserScript==
// @name         Fitgirl [ Youtube Preview ]
// @namespace    https://greasyfork.org/en/users/10118-drhouse
// @version      2.0
// @description  adds YouTube Preview links below video game titles, easily watch video of the game before playing it
// @include      https://fitgirl-repacks.site/*
// @include      https://duckduckgo.com/*
// @require      http://code.jquery.com/jquery-3.4.1.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js
// @author       drhouse
// @license      CC-BY-NC-SA-4.0
// @icon https://www.google.com/s2/favicons?sz=64&domain=fitgirl-repacks.site
// ==/UserScript==
/* global jQuery, $ */
this.$ = this.jQuery = jQuery.noConflict(true);
(function($){

    function videoize(){
        $('.nframe').remove() 
        $('br').remove() 
        $('article').each(function(index, value) {
            var x = $(this).find('.entry-title')
            var x2 = $(x).text()

            var x3 = encodeURIComponent(x2)

            $('<br>').insertAfter(x)
            var urlish = 'https://duckduckgo.com/?hps=1&q=%21+site%3Ayoutube.com+' + x3 + '+video+game'
            $('<div><a class="nframe" href=' + urlish + '>[ YouTube Preview ]</div>').addClass('entry-meta a').insertAfter(x)

            $(".nframe").click(function (e) {
                e.preventDefault();
                var url = $(this).attr("href");
                console.log('url='+url)
                var width = screen.width * 0.75;
                var height = screen.height * 0.75;
                var left = (screen.width - width) / 2;
                var top = (screen.height - height) / 2;
                var params = 'width=' + width + ', height=' + height;
                params += ', top=' + top + ', left=' + left;
                params += ', directories=no';
                params += ', location=no';
                params += ', menubar=no';
                params += ', resizable=yes';
                params += ', scrollbars=no';
                params += ', status=no';
                params += ', toolbar=no';
                var newwin = window.open(url, 'subpop', params);
                if (window.focus) {
                    newwin.focus()
                }
                return false;
            })
        })
    }

    videoize()
    setInterval(videoize, 2000)

    var str = document.title
    const regex = /^! site:youtube\.com/;

    if(window.location.host=='duckduckgo.com' && regex.test(str)){
        $("#search_button").click() 
    }  

})(jQuery);