/*! * test * (c) 2020 lincong1987 */ // ==UserScript== // @name 所有网站启用画中画 OPEN PIP IN ALL SITE // @namespace Violentmonkey Scripts // @match // @grant none // @version 1.3 // @author lincong1987 // @description 2020/10/10 下午3:21:48 // @require https://unpkg.com/jquery@3.5.1/dist/jquery.js // @require https://unpkg.com/vue@2.6.10/dist/vue.js // @downloadURL https://update.greasyfork.icu/scripts/412791/%E6%89%80%E6%9C%89%E7%BD%91%E7%AB%99%E5%90%AF%E7%94%A8%E7%94%BB%E4%B8%AD%E7%94%BB%20OPEN%20PIP%20IN%20ALL%20SITE.user.js // @updateURL https://update.greasyfork.icu/scripts/412791/%E6%89%80%E6%9C%89%E7%BD%91%E7%AB%99%E5%90%AF%E7%94%A8%E7%94%BB%E4%B8%AD%E7%94%BB%20OPEN%20PIP%20IN%20ALL%20SITE.meta.js // ==/UserScript== (function ($) { var appendToolbar = function ($video) { var width = $video.width() var position = $video.css('position') var parent_position = $video.parent().css('position') var parent_display = $video.parent().css('display') var $toolbar = $(`
`).data('video', $video) $video.after($toolbar) if (position === 'absolute' || position === 'fixed' || parent_position === 'relative' || parent_display === 'flex') { $toolbar.addClass('us_pip_toolbar__absolute') } else { $toolbar.width(width).addClass('us_pip_toolbar__static') } $toolbar.on('click', 'button', function () { $video.get(0).requestPictureInPicture() }) } var doFuck = function () { var $videos = $('video') $videos.each(function () { var $this = $(this) var isFucked = $this.data('isFucked') if (isFucked === true) { return } else { $this.data('isFucked', true) appendToolbar($this) } }) setTimeout(function () { doFuck() }, 5 * 1000) } doFuck() $('head').append(`