Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Script made by Lisa (Lisa#3995) */
- /* based on the code made by Hung Nguyen */
- /* [.pictureInPictureWindow-1B5qSe] - там, где transform; [.pictureInPictureVideo-20ZvXn] - ниже, внутри которого сразу span */
- window.GSSRBInterval = 'on';
- function makeResizableVS(div, dis, dsiz)
- {
- const VSDisElement = document.querySelector(dis);
- const VSDisSizElement = document.querySelector(dsiz);
- const VSElement = document.querySelector(div);
- const VSResizers = document.querySelectorAll(div + ' .resizer');
- const VSMinSize = 60;
- let original_width = 0;
- let original_height = 0;
- let original_x = 0;
- let original_y = 0;
- let original_mouse_x = 0;
- let original_mouse_y = 0;
- for (let i = 0;i < VSResizers.length; i++)
- {
- const currentResizer = VSResizers[i];
- currentResizer.addEventListener('mousedown', function(e)
- {
- e.preventDefault();
- original_width = parseFloat(getComputedStyle(VSElement, null).getPropertyValue('width').replace('px', ''));
- original_height = parseFloat(getComputedStyle(VSElement, null).getPropertyValue('height').replace('px', ''));
- original_x = VSElement.getBoundingClientRect().left;
- original_y = VSElement.getBoundingClientRect().top;
- original_mouse_x = e.pageX;
- original_mouse_y = e.pageY;
- window.addEventListener('mousemove', VSStartResize);
- window.addEventListener('mouseup', VSStopResize);
- });
- function VSStartResize(e)
- {
- if (currentResizer.classList.contains('bottom-right'))
- {
- const width = original_width + (e.pageX - original_mouse_x);
- const height = original_height + (e.pageY - original_mouse_y);
- if (width > VSMinSize)
- {
- VSElement.style.width = width + 'px';
- VSDisSizElement.style.setProperty('width', width + 'px');
- }
- if (height > VSMinSize)
- {
- VSElement.style.height = height + 'px';
- VSDisSizElement.style.setProperty('height', height + 'px');
- }
- }
- else if (currentResizer.classList.contains('bottom-left'))
- {
- const height = original_height + (e.pageY - original_mouse_y);
- const width = original_width - (e.pageX - original_mouse_x);
- if (height > VSMinSize)
- {
- VSElement.style.height = height + 'px';
- VSDisSizElement.style.setProperty('height', height + 'px');
- }
- if (width > VSMinSize)
- {
- VSElement.style.width = width + 'px';
- VSDisSizElement.style.setProperty('width', width + 'px');
- VSElement.style.left = original_x + (e.pageX - original_mouse_x) + 'px';
- VSDisElement.style.setProperty('transform', VSDisElement.style.getPropertyValue('transform').replace(VSDisElement.style.getPropertyValue('transform').split('translate')[1], VSDisElement.style.getPropertyValue('transform').split('translate')[1].replace(VSDisElement.style.getPropertyValue('transform').split('(')[1].split(')')[0].replace('px', ''), original_x + (e.pageX - original_mouse_x))));
- }
- }
- else if (currentResizer.classList.contains('top-right'))
- {
- const width = original_width + (e.pageX - original_mouse_x);
- const height = original_height - (e.pageY - original_mouse_y);
- if (width > VSMinSize)
- {
- VSElement.style.width = width + 'px';
- VSDisSizElement.style.setProperty('width', width + 'px');
- }
- if (height > VSMinSize)
- {
- VSElement.style.height = height + 'px';
- VSDisSizElement.style.setProperty('height', height + 'px');
- VSElement.style.top = original_y + (e.pageY - original_mouse_y) + 'px';
- VSDisElement.style.setProperty('transform', VSDisElement.style.getPropertyValue('transform').replace(VSDisElement.style.getPropertyValue('transform').split('translate')[2], VSDisElement.style.getPropertyValue('transform').split('translate')[2].replace(VSDisElement.style.getPropertyValue('transform').split('(')[2].split(')')[0].replace('px', ''), original_y + (e.pageY - original_mouse_y))));
- }
- }
- else
- {
- const width = original_width - (e.pageX - original_mouse_x);
- const height = original_height - (e.pageY - original_mouse_y);
- if (width > VSMinSize)
- {
- VSElement.style.width = width + 'px';
- VSDisSizElement.style.setProperty('width', width + 'px');
- VSElement.style.left = original_x + (e.pageX - original_mouse_x) + 'px';
- VSDisElement.style.setProperty('transform', VSDisElement.style.getPropertyValue('transform').replace(VSDisElement.style.getPropertyValue('transform').split('translate')[1], VSDisElement.style.getPropertyValue('transform').split('translate')[1].replace(VSDisElement.style.getPropertyValue('transform').split('(')[1].split(')')[0].replace('px', ''), original_x + (e.pageX - original_mouse_x))));
- }
- if (height > VSMinSize)
- {
- VSElement.style.height = height + 'px';
- VSDisSizElement.style.setProperty('height', height + 'px');
- VSElement.style.top = original_y + (e.pageY - original_mouse_y) + 'px';
- VSDisElement.style.setProperty('transform', VSDisElement.style.getPropertyValue('transform').replace(VSDisElement.style.getPropertyValue('transform').split('translate')[2], VSDisElement.style.getPropertyValue('transform').split('translate')[2].replace(VSDisElement.style.getPropertyValue('transform').split('(')[2].split(')')[0].replace('px', ''), original_y + (e.pageY - original_mouse_y))));
- }
- }
- }
- function VSStopResize()
- {
- window.removeEventListener('mousemove', VSStartResize);
- }
- }
- }
- function VShareWindowFix()
- {
- try
- {
- if((document.querySelector('.pictureInPictureVideo-20ZvXn') != null) && (document.querySelector('.VSResizableWindow') != null))
- {
- if((document.querySelector('.VSResizableWindow').style.getPropertyValue('left') != document.querySelector('.pictureInPictureWindow-1B5qSe').style.getPropertyValue('transform').split('(')[1].split(')')[0]) || (document.querySelector('.VSResizableWindow').style.getPropertyValue('top') != document.querySelector('.pictureInPictureWindow-1B5qSe').style.getPropertyValue('transform').split('(')[2].split(')')[0]) || (document.querySelector('.pictureInPictureVideo-20ZvXn').style.getPropertyValue('width') != document.querySelector('.VSResizableWindow').style.getPropertyValue('width')) || (document.querySelector('.pictureInPictureVideo-20ZvXn').style.getPropertyValue('height') != document.querySelector('.VSResizableWindow').style.getPropertyValue('height')))
- {
- document.querySelector('.VSResizableWindow').style.setProperty('left', document.querySelector('.pictureInPictureWindow-1B5qSe').style.getPropertyValue('transform').split('(')[1].split(')')[0]);
- document.querySelector('.VSResizableWindow').style.setProperty('top', document.querySelector('.pictureInPictureWindow-1B5qSe').style.getPropertyValue('transform').split('(')[2].split(')')[0]);
- }
- }
- } catch(err){}
- }
- var GSSRBInterval;
- GSSRBInterval = setInterval(function()
- {
- try
- {
- if(document.querySelector('.pictureInPictureVideo-20ZvXn') != null)
- {
- if(document.querySelector('.VSResizableWindow') == null && document.querySelector('.pictureInPictureWindow-1B5qSe') != null)
- {
- var VSResizableWindow;
- VSResizableWindow = document.createElement('div');
- VSResizableWindow.innerHTML =
- `
- <div class='resizers' style='border: 3px solid purple; box-sizing: border-box; margin-left: -3px; margin-top: -3px; width: calc(100% + 5px); height: calc(100% + 5px);'>
- <style type="text/css">.resizers .resizer { width: 10px; height: 10px; border-radius: 50%; background: white; border: 3px solid purple; opacity: 0.6; position: absolute; }</style>
- <div class='resizer top-left' style='left: -8px; top: -8px; cursor: nwse-resize;'></div>
- <div class='resizer top-right' style='right: -8px; top: -8px; cursor: nesw-resize;'></div>
- <div class='resizer bottom-left' style='left: -8px; bottom: -8px; cursor: nesw-resize;'></div>
- <div class='resizer bottom-right' style='right: -8px; bottom: -8px; cursor: nwse-resize;'></div>
- </div>
- `
- VSResizableWindow.setAttribute("class", "VSResizableWindow");
- VSResizableWindow.style = "width: 640px; height: 360px; position: absolute; overflow: visible;";
- document.querySelector('.pictureInPictureWindow-1B5qSe').before(VSResizableWindow);
- makeResizableVS('.VSResizableWindow', '.pictureInPictureWindow-1B5qSe', '.pictureInPictureVideo-20ZvXn');
- var VShareWindowFixInterval;
- VShareWindowFixInterval = setInterval(function()
- {
- VShareWindowFix();
- if (document.querySelector('.VSResizableWindow') == null)
- {
- clearInterval(VShareWindowFixInterval);
- }
- }, 0);
- }
- }
- else
- {
- if(document.querySelector('.VSResizableWindow') != null)
- {
- document.querySelector('.VSResizableWindow').remove();
- }
- }
- } catch(err){}
- if(window.GSSRBInterval == 'off')
- {
- clearInterval(GSSRBInterval);
- }
- },0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement