Last active
October 29, 2016 05:59
-
-
Save dimpurr/17872d8cae49f6ca2b62a4e12872ceba to your computer and use it in GitHub Desktop.
Bilibili-macOS-PIPScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Bilibili-macOS-PIPScript | |
// @namespace https://gist.github.com/dimpurr/17872d8cae49f6ca2b62a4e12872ceba | |
// @updateURL https://openuserjs.org/meta/dimpurr/Bilibili-macOS-PIPScript.meta.js | |
// @version 0.2 | |
// @description Enable PIP(Picture-In-Picture) on macOS for bilibili | |
// @author Dimpurr | |
// @include /^http:\/\/www.bilibili.com\/video\/av/ | |
// @include /^http:\/\/bangumi.bilibili.com\/anime\/v/ | |
// @run-at document-end | |
// ==/UserScript== | |
(function() { | |
// 'use strict'; | |
// diff | |
function PIP() { | |
var av = document.getElementsByTagName("video")[0]; | |
var bangumi = document.getElementsByClassName("bilibiliHtml5Player")[0]; | |
if (av !== undefined) { | |
av.setAttribute("controls", "controls"); | |
window.clearInterval(PIPInterval); | |
} else { | |
bangumi.contentDocument.getElementsByTagName("video")[0].setAttribute("controls", "controls"); | |
window.clearInterval(PIPInterval); | |
} | |
window.clearInterval(PIPInterval); | |
} | |
// diff | |
var PIPInterval = window.setInterval(PIP, 2000); | |
PIP(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment