Created
April 5, 2015 23:18
-
-
Save andre487/0337a216eb7043175c6e to your computer and use it in GitHub Desktop.
UserScripts
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 Открыть Видео с диска | |
| // @namespace yandex | |
| // @include https://yadi.sk/* | |
| // @version 1 | |
| // @grant none | |
| // ==/UserScript== | |
| window.addEventListener('load', main); | |
| function main() { | |
| let player = getPlayer(); | |
| if (player) { | |
| player.addEventListener('mousedown', onPlayerClick, true); | |
| } | |
| } | |
| function getPlayer() { | |
| return document.querySelector('.player-video-flash'); | |
| } | |
| function onPlayerClick(e) { | |
| if (confirm('Открыть в отдельной вкладке?')) { | |
| e.stopPropagation(); | |
| openPlayerWindow(this); | |
| } | |
| } | |
| function openPlayerWindow(player) { | |
| let win = window.open('about:blank'), | |
| loadHandler = onPlayerTabLoaded.bind(null, win, player.innerHTML); | |
| win.addEventListener('load', loadHandler); | |
| } | |
| function onPlayerTabLoaded(win, html) { | |
| let body = win.document.body; | |
| body.innerHTML = html; | |
| let player = body.firstChild; | |
| player.height = player.width = '100%'; | |
| player.style.height = player.style.width = '100%'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment