// ==UserScript== // @name InstaSynchP Layouts // @namespace InstaSynchP // @description Provides a larger layout and fullscreen mode // @version 1.0.4 // @author Zod- // @source https://github.com/Zod-/InstaSynchP-Layouts // @license GPL-3.0 // @include http://*.instasynch.com/* // @include http://instasynch.com/* // @include http://*.instasync.com/* // @include http://instasync.com/* // @grant none // @run-at document-start // @require https://greasyfork.org/scripts/5647-instasynchp-library/code/InstaSynchP%20Library.js // @require https://greasyfork.org/scripts/5832-jquery-fullscreen-page-load/code/jqueryfullscreen%20page%20load.js // @downloadURL none // ==/UserScript== function Layouts(version) { "use strict"; this.version = version; this.userFullscreenToggle = false; this.settings = [{ 'id': 'Layout', 'label': 'Layout', 'type': 'select', 'options': ['normal', 'large', 'huge'], 'default': 'normal', 'section': ['General'] }, { 'id': 'make-chat-visible', 'label': 'Make chat visible on message', 'type': 'checkbox', 'default': true, 'section': ['General', 'Fullscreen'] }, { 'id': 'chat-message-opacity', 'label': 'On Chat Message Opacity', 'type': 'int', 'title': '0-100', 'min': 0, 'max': 100, 'default': 100, 'size': 1, 'section': ['General', 'Fullscreen'] }, { 'id': 'chat-opacity', 'label': 'Chat Opacity', 'type': 'int', 'title': '0-100', 'min': 0, 'max': 100, 'default': 30, 'size': 1, 'section': ['General', 'Fullscreen'] }, { 'id': 'playlist-opacity', 'label': 'Playlist Opacity', 'type': 'int', 'title': '0-100', 'min': 0, 'max': 100, 'default': 30, 'size': 1, 'section': ['General', 'Fullscreen'] }, { 'id': 'poll-opacity', 'label': 'Poll Opacity', 'type': 'int', 'title': '0-100', 'min': 0, 'max': 100, 'default': 30, 'size': 1, 'section': ['General', 'Fullscreen'] }]; } function layoutsRef() { return window.plugins.layouts; } Layouts.prototype.addLayoutsOnce = function () { "use strict"; var th = layoutsRef(), i, layouts = [{ 'name': 'normalLayout', 'url': '' }, { 'name': 'largeLayout', 'url': 'https://cdn.rawgit.com/Zod-/InstaSynchP-Layouts/7d144b7ae7a5e0ad168f182c88b9312c8fb2beda/largeLayout.css' }, { 'name': 'hugeLayout', 'url': 'https://cdn.rawgit.com/Zod-/InstaSynchP-Layouts/b1e8f187eecce9ea4d552b97f76e8161ecfb3544/hugeLayout.css' }, { 'name': 'fullscreenLayout', 'url': 'https://cdn.rawgit.com/Zod-/InstaSynchP-Layouts/77eeab1d21ff09efdec77aa40d939ebadcdff9bb/fullscreenLayout.css' }]; for (i = 0; i < layouts.length; i += 1) { layouts[i].id = 'layout'; cssLoader.add(layouts[i]); } //style for the footer controls cssLoader.add({ 'name': 'layouts', 'url': 'https://cdn.rawgit.com/Zod-/InstaSynchP-Layouts/e2cb8b52f4dc76811c51c3121dbdd35d1de5b7d9/layouts.css', 'autoload': true }); events.on('SettingChange[Layout]', th.changeLayout); //reinitialise once the css has been loaded to fix the size events.on('CSSLoad[layout]', function () { $("#videos").data("jsp").reinitialise(); }); }; Layouts.prototype.setUpFullscreenOnce = function () { "use strict"; var th = layoutsRef(), chatVisibleTimer; //make poll visible in fullscreen when it is hidden events.on('CreatePoll', function () { $('.poll-container').removeClass('poll-container2'); $('#hide-poll').removeClass('hide-poll2'); }); //make chat visible for 5 seconds on every message function chatVisibility() { if (!gmc.get('make-chat-visible')) { return; } $('#chat .left').css('opacity', gmc.get('chat-message-opacity') / 100.0); if (chatVisibleTimer) { clearTimeout(chatVisibleTimer); chatVisibleTimer = undefined; } chatVisibleTimer = setTimeout(function () { $('#chat .left').css('opacity', gmc.get('chat-opacity') / 100.0); }, 3000); } //on fullscreen change $(document).bind('fscreenchange', function () { if ($.fullscreen.isFullScreen()) { if (th.userFullscreenToggle) { events.on('AddMessage', chatVisibility); cssLoader.load('fullscreenLayout'); //the event somehow doesn't affect it when changing to fullscreen so fire it by hand again after a short time setTimeout(function () { events.fire('CSSLoad[layout]'); }, 1500); //set bars and elements to their opacity values $('#chat .left').css('opacity', gmc.get('chat-opacity') / 100.0); $('#playlist').css('opacity', gmc.get('playlist-opacity') / 100.0); $('.poll-container').css('opacity', gmc.get('poll-opacity') / 100.0); $('#chat-slider').slider('option', 'value', gmc.get('chat-opacity')); $('#poll-slider').slider('option', 'value', gmc.get('poll-opacity')); $('#playlist-slider').slider('option', 'value', gmc.get('playlist-opacity')); } } else { //turn back to normal if user canceled fullscreen if (th.userFullscreenToggle) { events.unbind('AddMessage', chatVisibility); cssLoader.load('{0}Layout'.format(gmc.get('Layout'))); if (chatVisibleTimer) { clearTimeout(chatVisibleTimer); chatVisibleTimer = undefined; } $('#chat .left').css('opacity', '1'); $('#playlist').css('opacity', '1'); $('.poll-container').css('opacity', '1'); } th.userFullscreenToggle = false; } }); }; Layouts.prototype.addLayouts = function () { "use strict"; var th = layoutsRef(), i, layouts = [ 'normal', 'large', 'huge' ]; //change layout if it is a different one and then save function setLayout(event) { if (gmc.get('Layout') !== $(event.currentTarget).text()) { gmc.set('Layout', $(event.currentTarget).text()); plugins.settings.save(); } } $('