Vertical Stream Magic

Adjust Twitch streams for a vertical orientated monitor.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name          Vertical Stream Magic
// @namespace     http://greasyfork.org/users/2240-doodles
// @author        Doodles
// @version       4
// @description   Adjust Twitch streams for a vertical orientated monitor.
// @include       *://www.twitch.tv/*
// @require       https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
// @grant         none
// @updateVersion 4
// @noframes
// ==/UserScript==

this.$ = this.jQuery = jQuery.noConflict(true);
$(document).ready(function () {
	'use strict';
	function resizeIframes() {
		var _width = window.innerWidth;
		var _height = window.innerHeight;
		var streamFrameHeight = Math.floor((_width / 16) * 9);
		$("iframe#vsmStream").attr("width", _width).attr("height", streamFrameHeight);
		$("iframe#vsmChat").attr("width", _width).attr("height", _height - streamFrameHeight);
	}
	var notchannels = ["dashboard", "directory", "friends", "jobs", "login", "logout", "manager", "store", "subscriptions", "settings", "videos"];
	function channelCatcher() {
		var channelName = document.URL.split("twitch.tv/")[1].split("/")[0].split("&")[0].split("#")[0];
		if(document.URL.split("twitch.tv/")[1].length > 0 && document.URL.split("twitch.tv/")[1].split("/").length == 1 && notchannels.indexOf(channelName) == -1){
			window.location.assign(document.URL.replace("twitch.tv/", "twitch.tv/vsm/"));
		}
	}
	if(document.URL.indexOf("twitch.tv/vsm/") != -1){
		var channelName = document.URL.split("twitch.tv/vsm/")[1].split("/")[0].split("&")[0].split("#")[0];
		$('script').each(function () { $(this).remove(); });
		$('body').html('' +
			'<iframe src="https://player.twitch.tv/?channel='+channelName+'" id="vsmStream" height="450" width="800" frameborder="0" scrolling="no" allowfullscreen="true"></iframe>' +
			'<iframe src="https://www.twitch.tv/'+channelName+'/chat?popout=" id="vsmChat" height="450" width="800" frameborder="0" scrolling="no" allowfullscreen="true"></iframe>' +
		'');
		$('head').html('<title>'+channelName+'</title>');
		$('<style></style>').prop('type', 'text/css').html('' +
			'html{height:100%;}body{padding:0 0 0 0;margin:0 0 0 0;background-color:#333;}iframe#vsmStream, iframe#vsmChat{padding:0 0 0 0;margin:0 0 0 0;display:block;}' +
		'').appendTo('head');
		resizeIframes();
		$(window).resize(resizeIframes);
	}else{
		channelCatcher();
		var observer = new MutationObserver(channelCatcher);
		observer.observe(document.body, {childList: true});
	}
});