// ==UserScript== // @name Rotten Tomatoes: YouTube Trailers Link // @description Adds a YouTube search link to Rotten Tomatoes pages // @version 0.7 // @author mica // @namespace greasyfork.org/users/12559 // @match https://www.rottentomatoes.com/m/* // @match https://www.rottentomatoes.com/tv/* // @license MIT // @downloadURL none // ==/UserScript== var link = 'https://www.youtube.com/results?search_query=' + encodeURIComponent(document.title.replace(' - Rotten Tomatoes','')) + ' trailer' var html = `

Watch Trailers on

` if (location.pathname.match(/^\/m/g)) { document.querySelector('#topSection section h2').style.clear = 'left' document.querySelector('#topSection section h2').style.paddingTop = '30px' document.querySelector('#topSection section').insertAdjacentHTML('afterbegin', html); } else { document.querySelector('#topSection ~ section h2').style.clear = 'left' document.querySelector('#topSection ~ section h2').style.paddingTop = '30px' document.querySelector('#topSection ~ section').insertAdjacentHTML('afterbegin', html); }