Last active
November 1, 2016 15:48
-
-
Save j4ckth3r1pp3r/9dbf4a3667495b04076d524b4e253a2e to your computer and use it in GitHub Desktop.
Скрипт для TamperMonkey для сайта fs.to
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
// ==UserScript== | |
// @name AdLess FS.TO Player | |
// @namespace http://j4ck.lp5.com.ua/myshows/ | |
// @version 0.4 | |
// @description Меняет плеер сайта на HTML5 встроенный и добавляет кнопку MyShows и фон для сериалов оттуда | |
// @author J4ck Th3 R1pp3r | |
// @match http://fs.to/* | |
// @connect j4ck.lp5.com.ua | |
// @grant GM_xmlhttpRequest | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setTimeout(function() { | |
GM_xmlhttpRequest({ | |
method: "GET", | |
url: 'http://j4ck.lp5.com.ua/myshows/?query='+$('div[itemprop=alternativeHeadline]').text(), | |
onload: function(response) { | |
//Получаем JSON | |
var jsonStr = JSON.parse(response.responseText); | |
//Добавляем ссылку возле плеера, убираем рекламный фон и ставим фон с MyShows | |
$('body').attr('style', 'background: url('+jsonStr.background+') top center no-repeat !important;background-size:cover !important;background-attachment: fixed !important;'); | |
//Вставляем ссылку на сериал на странице сериала | |
$('body').append('<a href="'+jsonStr.link+'" target="_blank" id="myshows"><img src="https://myshows.me/shared/img/fe/logo.png"></a>'); | |
} | |
}); | |
}, 200); | |
var playerWidthPx = 993; | |
var playerHeightPx = Math.round(playerWidthPx / 1.78); | |
function showPlayer() { | |
$('#j4ck-wrapper').show(); | |
$('#j4ck-wrapper').find('video')[0].play(); | |
$('.l-content-wrap').css('visibility', 'hidden'); | |
//---- Скрываем ссылку разворота | |
$('#return').hide(); | |
} | |
function hidePlayer() { | |
$('#j4ck-wrapper').hide(); | |
$('#j4ck-wrapper').find('video')[0].pause(); | |
$('.l-content-wrap').css('visibility', 'visible'); | |
//---- Показываем ссылку | |
$('#return').show(); | |
} | |
//---- Убираем "рекламный фон" (да, по другому никак, хочешь - убедись сам, умник) | |
$('.l-body-branding').css({'visibility': 'hidden'}); | |
//---- Кликаем по ссылки файлы и папки | |
$('#page-item-file-list a').click(); | |
$('#adsProxy-video').remove(); | |
$('.l-body-branding').text(''); | |
//---- Добавляем стили | |
$('head style').append('body, .l-body-branding {background: #13223a !important;}'); | |
$('head style').append('#j4ck-wrapper {display: none; width:100%; height: 100%; position: fixed; left: 0%; top: 0%; z-index: 9999;}'); | |
$('head style').append('#j4ck-wrapper video {margin: 0 auto; display: block;}'); | |
$('head style').append('#return {display: none; background: rgb(48, 58, 74); position: fixed; left: calc(50% - '+(playerWidthPx/2)+'px - 100px); top: 0%; z-index: 9999;color:#fff;padding:10px; cursor: pointer}'); | |
$('head style').append('#myshows {display: block; background: rgb(48, 58, 74); height: 15px; position: fixed; left: calc(50% - '+(playerWidthPx/2)+'px - 215px); top: 0%; z-index: 9999;color:#fff;padding:10px; cursor: pointer}'); | |
$('head style').append('#myshows img {height: 15px;}'); | |
$('head style').append('#j4ck-wrapper div {color: rgb(255, 255, 255);width: 993px;margin: 50px auto 10px;font-size: 20px;}'); | |
$('head style').append('#j4ck-wrapper .sub-title {margin: 0px auto; font-size: 16px;}'); | |
//---- Реклама на странице сериала | |
$('.b-styled__item-central, .b-styled__content-right').remove(); | |
//---- Создаем контейнер и ссылку разворота | |
$('body').append('<div id="return">Развернуть</div>'); | |
$('#return').click(function () { | |
showPlayer(); | |
}); | |
$('body').append('<div id="j4ck-wrapper"><div class="title"></div><div class="sub-title"></div></div>'); | |
$('#j4ck-wrapper').append('<video width="'+playerWidthPx+'" height="'+playerHeightPx+'" controls><source src=""></video>'); | |
$('#j4ck-wrapper').click(function(e) { | |
if (e.target != this) return; | |
hidePlayer(); | |
}); | |
//---- Блок кода связанный с открыванием видео по ссылке в списке файлов | |
$('.b-files-folders').click(function() { | |
var currentContect = this; | |
//---- Без задержки js не успевает подхватить созданные контейнеры | |
setTimeout(function() { | |
$('.b-file-new__link-material', currentContect) | |
.removeClass('b-file-new__link-material') | |
.click(function(e) { | |
e.preventDefault(); | |
var directVideoLink = $(this).parent('li').find('.b-file-new__link-material-download').attr('href'); | |
var episodeNameString = $(this).find('.b-file-new__link-material-filename-text').text(); | |
var episodeInfo = episodeNameString.match(/\.[sS](\d*)[eE](\d*)\./); | |
//---- Показываем контейнер с видео, подставляем ссылку и загружаем видео, скрываем сайт | |
$('#j4ck-wrapper').find('video')[0].load(); | |
$('#j4ck-wrapper').find('.title').text($('.b-tab-item__title-inner span[itemprop=name]').text()); | |
$('#j4ck-wrapper').find('.sub-title').text('Сезон: '+episodeInfo[1]+' / Серия: '+episodeInfo[2]); | |
$('#j4ck-wrapper').find('source').attr('src', directVideoLink); | |
showPlayer(); | |
}); | |
}, 1000); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment