UNPKG

niconizer

Version:

A desktop application that displays plain text, images, or any other HTML content on the screen, like nicovideo or bilibili.

1 lines 1.51 kB
let e;var n=require("electron"),t=require("node:events"),o=require("ws"),i=require("file-uri-to-path");function r(e){return e&&e.__esModule?e.default:e}async function s(e=25252){let n=new o.Server({host:"127.0.0.1",port:e});return n.on("connection",(e,t)=>{t.headers.origin?.startsWith("file:")?e.on("n:comment",n=>e.send(n)):e.on("message",e=>{let t=e.toString();for(let e of(console.log("[%s] comment: %s",new Date().toISOString(),t),n.clients))e.emit("n:comment",t)})}),await (0,t.once)(n,"listening"),n}var l={};l=new URL("icon_16x16.e7d307e5.png","file:"+__filename).toString();var a={};function c(){!function(){if(e)return;let{size:t}=(0,n.screen).getPrimaryDisplay();(e=new n.BrowserWindow({x:0,y:0,width:t.width,height:t.height,frame:!1,transparent:!0,alwaysOnTop:!0,hasShadow:!1})).setIgnoreMouseEvents(!0),e.setVisibleOnAllWorkspaces(!0),e.loadURL(/*@__PURE__*/r(a)).catch(e=>{throw e}),e.on("closed",()=>{e=void 0})}()}function p(){e?.close()}function u(){(0,n.app).quit()}a=new URL("content.c9723793.html","file:"+__filename).toString(),n.app.dock?.hide(),(0,n.app).on("ready",()=>{new n.Tray(r(i)(/*@__PURE__*/r(l))).setContextMenu((0,n.Menu).buildFromTemplate([{label:"Start",click:c},{label:"Stop",click:p},{label:"Quit",click:u}])),setImmediate(c)}),(0,n.app).on("window-all-closed",()=>{}),s("string"==typeof process.env.PORT?Number.parseInt(process.env.PORT,10):void 0).then(e=>{console.log(`listening on port ${e.options.port}`)},function(e){if("string"==typeof e)throw TypeError(e);throw e});