Greasy Fork

Greasy Fork is available in English.

巴哈浮動影片

在巴哈姆特影片加入浮動視窗按鈕

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name 巴哈浮動影片
// @namespace https://home.gamer.com.tw/Mogeko12345
// @version 1.0.1
// @description 在巴哈姆特影片加入浮動視窗按鈕
// @author mogeko12345
// @match https://forum.gamer.com.tw/C.php*
// @grant unsafeWindow
// @require https://code.jquery.com/jquery-3.3.1.min.js
// @require http://greasyfork.icu/scripts/31940-waitforkeyelements/code/waitForKeyElements.js?version=209282
// ==/UserScript==

(function(){
  var style = document.createElement("style");
  style.textContent = ".float-video{position:fixed;left:5px;bottom:5px;width:16vw;height:9vw;padding-bottom:0%;z-index:100;}.float-button{position:absolute;top:0px;right:0px;width:26px;height:26px;font-size:24px;font-weight:bold;color:#ffffff;opacity:0.9;background-color:transparent;border:0;}.float-video .float-button{width:20px;height:20px;font-size:18px;}";
  document.getElementsByTagName("head")[0].appendChild(style);

  var current = null;

  function clickButton(){
    var parent = this.parentElement;
    if(parent.classList.contains("float-video")){
      parent.classList.toggle("float-video");
      this.textContent = (this.textContent === "↙") ? "↗" : "↙";
      current = null;
    }
    else{
      if(current){
        current.parentElement.classList.toggle("float-video");
        current.textContent = (current.textContent === "↙") ? "↗" : "↙";
      }
      parent.classList.toggle("float-video");
      this.textContent = (this.textContent === "↙") ? "↗" : "↙";
      current = this;
    }
  }

  function addButton(node){
    var n = node[0];
    var button = document.createElement("button");
    button.className = "float-button";
    button.textContent = "↙";
    button.addEventListener("click", clickButton);
    n.appendChild(button);
  }

  waitForKeyElements(".videoWrapper.video-youtube", addButton);
})();