Last active
August 29, 2015 14:27
-
-
Save outring/e765cd8e6a977c160088 to your computer and use it in GitHub Desktop.
This file contains 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
(function () { | |
if (location.host !== "kino.pub") { | |
alert("Для начала надо зайти на kino.pub, например."); | |
return; | |
} | |
var errorHeading = "Что-то пошло не так. \n"; | |
var windowId = "linksBookmarklet"; | |
var windowStyle = { | |
position: "fixed", | |
top: 0, | |
left: 0, | |
right: 0, | |
bottom: 0, | |
width: 250, | |
height: 100, | |
margin: "auto", | |
padding: "10px 20px", | |
textAlign: "center", | |
backgroundColor: "#666666", | |
borderRadius: "15px" | |
}; | |
var rowStyle = { | |
display: "block", | |
padding: "10px 0" | |
}; | |
var videoId = (location.pathname.match(/^\/item\/view\/(\d+)/) || [])[1]; | |
if (!videoId) { | |
alert("Надо зайти на страницу с видео и тогда всё получится."); | |
return; | |
} | |
$("#" + windowId).remove(); | |
var frame = document.querySelector("#player iframe"); | |
if (!frame) { | |
alert(errorHeading + "Вы как будто бы открыли сайт не на мобильном устройстве. Так работать не будет."); | |
} | |
var source = frame.contentDocument.querySelector("source"); | |
if (!source) { | |
alert(errorHeading + "Плеер как будто бы не инициализировался. Досада.") | |
} | |
var links = [ | |
{ | |
url: source.src, | |
name: "Дорожка по умолчанию" | |
}, | |
{ | |
url: getLocalizedSource(source.src), | |
name: "Следующая за ней" | |
} | |
]; | |
var $window = $("<div />", { id: windowId, css: windowStyle }).appendTo("body"); | |
$.each(links, function (_, link) { | |
$("<a />", { css: rowStyle, href: link.url }) | |
.text(link.name) | |
.appendTo($window); | |
}); | |
function getLocalizedSource(source) { | |
return source.replace("?", "?audioIndex=1&"); | |
} | |
})(); |
This file contains 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
javascript:(function(){function j(a){return a.replace("?","?audioIndex=1&")}if("kino.pub"!==location.host)return alert("Для начала надо зайти на kino.pub, например."),void 0;var a="Что-то пошло не так. \n",b="linksBookmarklet",c={position:"fixed",top:0,left:0,right:0,bottom:0,width:250,height:100,margin:"auto",padding:"10px 20px",textAlign:"center",backgroundColor:"#666666",borderRadius:"15px"},d={display:"block",padding:"10px 0"},e=(location.pathname.match(/^\/item\/view\/(\d+)/)||[])[1];if(!e)return alert("Надо зайти на страницу с видео и тогда всё получится."),void 0;$("#"+b).remove();var f=document.querySelector("#player iframe");f||alert(a+"Вы как будто бы открыли сайт не на мобильном устройстве. Так работать не будет.");var g=f.contentDocument.querySelector("source");g||alert(a+"Плеер как будто бы не инициализировался. Досада.");var h=[{url:g.src,name:"Дорожка по умолчанию"},{url:j(g.src),name:"Следующая за ней"}],i=$("<div />",{id:b,css:c}).appendTo("body");$.each(h,function(a,b){$("<a />",{css:d,href:b.url}).text(b.name).appendTo(i)})})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment