Created
January 10, 2015 17:24
-
-
Save avaly/90250cf76f047aaff9ce to your computer and use it in GitHub Desktop.
giff trailer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name GIFF | |
// @namespace http://userscripts.com/none | |
// @include http://*.filmfestival.org/filmfestival/info/*/festivalprogram/programentry?* | |
// ==/UserScript== | |
var h1 = document.getElementsByTagName('h1')[0], | |
title = h1.innerHTML, | |
titleRealElem = document.querySelector('.movieDetails p:nth-child(5)'), | |
titleReal = titleRealElem ? titleRealElem.innerHTML.replace(/<strong>.+<\/strong>/, '').replace('<br>', '') : '', | |
a = document.createElement('a'), | |
ar = document.createElement('a'); | |
a.innerHTML = 'find trailer'; | |
a.href = 'http://www.youtube.com/results?search_query=' + title.replace(/ /g, '+') + '+trailer'; | |
a.setAttribute('target', '_blank'); | |
a.style.padding = '0 .5em'; | |
h1.appendChild(a); | |
if (titleReal) { | |
ar.innerHTML = 'real trailer'; | |
ar.href = 'http://www.youtube.com/results?search_query=' + titleReal.replace(/ /g, '+') + '+trailer'; | |
ar.setAttribute('target', '_blank'); | |
ar.style.padding = '0 .5em'; | |
h1.appendChild(ar); | |
} | |
h1.parentNode.setAttribute('width', '75%'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment