adds YouTube Preview and Review links below video game titles, easily watch a video or review of the game before playing it
// ==UserScript== // @name Fitgirl [ Youtube Preview ] // @namespace https://greasyfork.org/en/users/10118-drhouse // @version 2.3 // @description adds YouTube Preview and Review links below video game titles, easily watch a video or review 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 regex1 = /^(.*?)(?=\s+–)/; var regex2 = /^(.*?)(?=\s+\+)/; var r###lt = x2.match(regex1); if(r###lt === null){ r###lt = x2.match(regex2); if(r###lt === null){ console.log('r###lt1='+r###lt) var x3 = encodeURIComponent(x2) } else { r###lt = r###lt[1]; console.log('r###lt2='+r###lt) x3 = encodeURIComponent(r###lt) } } else { r###lt = r###lt[1]; console.log('r###lt3='+r###lt) x3 = encodeURIComponent(r###lt) } $('<br>').insertAfter(x) var urlish = 'https://duckduckgo.com/?hps=1&q=%21+site%3Ayoutube.com+' + x3 + '+gameplay+video+game' $('<div><a class="nframe" href=' + urlish + '>[ YouTube Gameplay ]</div>').addClass('entry-meta a').insertAfter(x) var urlish2 = 'https://duckduckgo.com/?hps=1&q=%21+site%3Ayoutube.com+' + x3 + '+review+video+game' $('<div><a class="nframe" href=' + urlish2 + '>[ YouTube Review ]</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);