Greasy Fork is available in English.
移动端Yandex浏览器看视频全屏时强制为横屏观看(安卓已经过测试运行,ios并未测试)
当前为
// ==UserScript==
// @name Yandex视频横屏插件
// @name:en Yandex Video Player Horizontal Screen Plug-in
// @description 移动端Yandex浏览器看视频全屏时强制为横屏观看(安卓已经过测试运行,ios并未测试)
// @description:en Yandex browser is set to play horizontally when viewing full-screen video. This is for Android, and IOS is not tested.
// @version 1.1.2
// @author Xavier
// @namespace http://greasyfork.icu/zh-CN/users/128493
// @match *://*/*
// @grant none
// @run-at document-end
// @note 更新日志:1.添加竖屏模式。有些视频更适宜在竖屏状态下观看,全屏状态下,手机竖直摆放时会重新回到竖屏模式。2.添加双击全屏功能。一些网站全屏按钮无法使视频进入全屏模式(例如m.bilibili.com),新增在视频播放状态下,双击全屏(支持双击退出全屏)。该功能需要关闭yandex浏览器的"忽略网站的禁止字体缩放请求"功能,不关闭双击会缩放网页。
// @note Yandex浏览器版本18.11.1(安卓自2018年12月26日,版本号979),切换竖屏会退出全屏状态,暂时取消竖屏模式,其他保持不变。不是该版本浏览器,有竖屏观看需要的可以安装本脚本历史版本1.1.1。
// ==/UserScript==
(function() {
'use strict';
var videoEle=document.getElementsByTagName("video");
var videoplay=null,vi=0,vClick=0;
function setVideo(e){videoplay=this;}
function getVideoPlay() {
if(videoEle.length>0){
for(vi=0;vi<videoEle.length;vi++){
videoEle[vi].addEventListener("play",setVideo,false);
}
document.body.removeEventListener("click",getVideoPlay, false);
}else{
if(vClick<3){vClick++;}
else{
document.body.removeEventListener("click",getVideoPlay, false);
document.body.removeEventListener("dblclick",dblfull, false);
document.removeEventListener("webkitfullscreenchange",fullchange,false);
}
}
}
function dblfull(){
if(videoplay!=null){
if(document.webkitFullscreenElement){
videoplay.webkitExitFullscreen();
}else{
videoplay.webkitRequestFullScreen();
}
}
}
document.body.addEventListener("click",getVideoPlay,false);
document.body.addEventListener("dblclick",dblfull,false);
var oriHway="landscape-primary";
var oriHtemp="",oriHgamma=0,oriHbeta=0;
function orientationHandler(event) {
oriHgamma=Math.round(event.gamma);
oriHbeta=Math.abs(Math.round(event.beta));
if((oriHbeta<35 && Math.abs(oriHgamma)>30) || (oriHbeta>145 && Math.abs(oriHgamma)>30)){
oriHtemp=((oriHgamma>30 && oriHbeta<35) || (oriHgamma<-30 && oriHbeta>145)) ? "landscape-secondary" : "landscape-primary";
}
if(oriHway!=oriHtemp){
oriHway=oriHtemp;
screen.orientation.lock(oriHway);
}
}
function fullchange(){
try{
if(document.webkitFullscreenElement){
screen.orientation.lock(oriHway);
window.addEventListener("deviceorientation", orientationHandler, false);
}else{
window.removeEventListener("deviceorientation", orientationHandler, false);
}
}
catch (e) {
alert("Your browser does not support this script !");
}
}
document.addEventListener("webkitfullscreenchange",fullchange,false);
})();