nickyx3gmail.com / VK Video Expander

// ==UserScript==
// @name         VK Video Expander
// @namespace    http://tampermonkey.net/
// @version      2025-04-14
// @description  Expand VK Video to Full Page Width
// @author       nickyx3@gmail.com
// @match        https://vkvideo.ru/video-*
// @match        https://vk.com/video-*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=vk.com
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js
// @run-at       document-idle
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    var $ = window.jQuery;

    let buttonHTML = '<style>.videoplayer_fw_icon {width: 24px;}</style><div class="videoplayer_controls_item videoplayer_btn videoplayer_btn_full_width" role="button" tabindex="0" aria-label="Полная ширина" title="Полная ширина"><svg class="videoplayer_btn_icon videoplayer_fw_icon" xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#fff"><path d="M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm0-80h40v-480h-40v480Zm120 0h400v-480H280v480Zm480 0h40v-480h-40v480ZM280-720v480-480Z"/></svg></div>';
    $('body').on('mouseover','[id="video_player"]',function(e){
        let fsButton = $('.videoplayer_btn_fullscreen');
        let parentBlock = $(fsButton).parent();
        let expandButton = $(parentBlock).find( $('.videoplayer_btn_full_width') );
        if ( $(expandButton).length === 0 ) {
            $(fsButton).before(buttonHTML);
            let expandButtonObj = $(parentBlock).find( $('.videoplayer_btn_full_width') );
            if ( $(expandButtonObj).length > 0 ) {
                $(expandButtonObj).on('click',function(e){
                    let rightColumn = $('body').find( $('.vkuiInternalTwoColumnLayout .vkuiInternalTwoColumnLayoutColumn:last-child') );
                    if ( $(rightColumn).length > 0 ) {
                        if ( $(rightColumn).css('display') === 'block' ) {
                            $(rightColumn).css('display','none');
                        } else {
                            $(rightColumn).css('display','block');
                        }
                    }
                });
            }
        }
    });



})();