FURSTREAM stream mod

Make the stream player take all available width

当前为 2014-06-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name FURSTREAM stream mod
  3. // @namespace furstre.am
  4. // @description Make the stream player take all available width
  5. // @include https://furstre.am/stream/*
  6. // @version 1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. var ratio = {x:16,y:10}
  11.  
  12. $(window).load(function(){
  13. $(window).resize()
  14. var select = $(document.createElement("select")).addClass("btn btn-default pull-right")
  15. $(select).append($(document.createElement("option")).attr("value", '{"x":16,"y":10}').html("16:10 ratio"))
  16. $(select).append($(document.createElement("option")).attr("value", '{"x":16,"y":9}').html("16:9 ratio"))
  17. $(select).append($(document.createElement("option")).attr("value", '{"x":16,"y":12}').html("4:3 ratio"))
  18. $(select).append($(document.createElement("option")).attr("value", '{"x":15,"y":12}').html("5:4 ratio"))
  19. $(select).change(function(e){
  20. var o = $(".center .row select").get(0);
  21. ratio = $.parseJSON(o.value);
  22. $(window).resize();
  23. })
  24. $("#follow-stream").after(select)
  25. })
  26.  
  27. $(window).resize(function(e){
  28. var streamwidth = $("body").width() - $("#flex__1").width() - $("#chat").width();
  29. $(".center").css({ "margin-right" : "0", "margin-left" : "0" , "width" : streamwidth+"px" })
  30. var factor = Math.floor((streamwidth - 26) / ratio.x)
  31. $("div.player-wrap").css({ "width" : (factor * ratio.x)+"px", "height" : (factor * ratio.y)+"px"})
  32. $("div#player").css({ "width" : (factor * ratio.x)+"px", "height" : (factor * ratio.y)+"px"})
  33. })
  34.