Page FPS

Inject FPS indicator into current page.

当前为 2019-04-09 提交的版本,查看 最新版本

// ==UserScript==
// @name         Page FPS
// @version      1.0
// @description  Inject FPS indicator into current page.
// @author       hustcc
// @match        https://**/*
// @noframes
// @run-at       document-end
// @namespace https://atool.vip
// ==/UserScript==

(function() {
    'use strict';

    !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PF=e():t.PF=e()}(window,function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=5)}([function(t,e,o){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.clock="object"===("undefined"==typeof performance?"undefined":n(performance))&&performance.now?performance:Date},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=o(2);e.default=n.PF},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=o(3),r=o(4),i=window.devicePixelRatio,c=function(){function t(){var t=this;this.fps=new n.FPS,this.timer=new r.Timer(function(){t.draw()})}return t.prototype.start=function(){this.c&&this.ctx||this.createCanvas(),this.fps.start(),this.timer.start()},t.prototype.stop=function(){this.fps.stop(),this.timer.stop(),this.c.parentNode.removeChild(this.c),this.c=void 0,this.ctx=void 0},t.prototype.collect=function(){var t=this.fps.sample();return Object.assign({},{fps:t})},t.prototype.createCanvas=function(){this.c=document.createElement("canvas");this.c.setAttribute("style","position: fixed; bottom: 4px; left: 4px; width: 80px; height: 12px"),this.c.width=80*i,this.c.height=12*i,document.body.appendChild(this.c),this.ctx=this.c.getContext("2d"),this.ctx.globalAlpha=.5,this.ctx.fillStyle="black",this.ctx.font=10*i+"px Menlo",this.ctx.textBaseline="middle"},t.prototype.getDrawTexts=function(t){return t?["FPS: "+t.fps.toFixed(3)]:[""]},t.prototype.draw=function(){var t=this.collect(),e=this.getDrawTexts(t);this.ctx.clearRect(0,0,this.c.width,this.c.height),this.ctx.fillText(e[0],2,7*i)},t.ver="1.0.0",t}();e.PF=c},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=o(0),r=function(){function t(){this.buffer=[],this.raf=-1}return t.prototype.start=function(){var t=this;this.raf=window.requestAnimationFrame(function(){t.buffer.push(n.clock.now()),t.buffer.length>60&&t.buffer.shift(),t.start()})},t.prototype.stop=function(){window.cancelAnimationFrame(this.raf),this.buffer=[],this.raf=-1},t.prototype.sample=function(){var t=this.buffer[0],e=this.buffer[this.buffer.length-1]-t;return e?1e3*(this.buffer.length-1)/e:60},t}();e.FPS=r},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=o(0),r=function(){function t(t,e){void 0===e&&(e=60),this.prev=0,this.cb=t,this.delay=e}return t.prototype.start=function(){var t=this;this.raf=window.requestAnimationFrame(function(){var e=n.clock.now();e>t.prev+t.delay&&(t.prev=e,t.cb(0)),t.start()})},t.prototype.stop=function(){window.cancelAnimationFrame(this.raf),this.raf=void 0},t}();e.Timer=r},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),(new(o(1).default)).start()}])});
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址