ipwebcam resize fix

for the pas one. my own use, probably not for you.

  1. // ==UserScript==
  2. // @name ipwebcam resize fix
  3. // @namespace http://lolno.com
  4. // @version 0.1
  5. // @description for the pas one. my own use, probably not for you.
  6. // @author Dobby233Liu
  7. // @match *://*/browserfs.html
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. const $exists = function(s){
  12. return !(document.querySelectorAll(s).length <= 0);
  13. };
  14.  
  15. const $obj = function(s){
  16. if(!$exists(s)) throw DOMException("Nonexist element/selector.");
  17. return (document.querySelectorAll(s).length == 1 ? document.querySelector(s) : document.querySelectorAll(s));
  18. };
  19.  
  20. (function() {
  21. 'use strict';
  22.  
  23. window.onresize = function(e){
  24. document.body.style.overflow = "hidden";
  25. if(!$exists("#img1") && !$exists("#img2")) throw Error("!$exists('#img1') && !$exists('#img2'). That shouldn't happening.")
  26. if($exists("#img1")){
  27. $obj("#img1").width = window.innerWidth;
  28. $obj("#img1").height = window.innerHeight;
  29. $obj("#img1").onclick = null;
  30. }
  31. if($exists("#img2")){
  32. $obj("#img2").width = window.innerWidth;
  33. $obj("#img2").height = window.innerHeight;
  34. $obj("#img2").onclick = null;
  35. }
  36. };
  37. window.onresize();
  38. })();