VCに接続されている時間を表示するDiscordプラグイン | Discord plugin that displays how long connected to VC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//META{"name":"ConnectionTime","website":"https://kataba.me/","source":"https://gist.github.com/katabame/ef65c6379c8d50af8702c5932c6dbf5b"}*// | |
/* | |
MIT License | |
Copyright (c) 2018 katabame | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE. | |
*/ | |
var ConnectionTime_Interval; | |
var sec; | |
class ConnectionTime | |
{ | |
getName() | |
{ | |
return "ConnectionTime"; | |
} | |
getDescription() | |
{ | |
return document.documentElement.lang == "ja" ? "VCに接続されている時間を表示します" : "Displays how long connected to VC"; | |
} | |
getVersion() | |
{ | |
return "1.3.0"; | |
// Tested on Discord Stable build 91948 | |
} | |
getAuthor() | |
{ | |
return "katabame, micelle"; | |
} | |
/* | |
load() | |
{ | |
// Load Zere's Library Script. This library used for plugin update check. | |
BdApi.linkJS("zeresLibraryScript", "https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js"); | |
// Retrieve update from katabame's source | |
ZeresPluginLibrary.PluginUpdater.checkForUpdate(this.getName(), this.getVersion(), "https://gist.github.com/katabame/ef65c6379c8d50af8702c5932c6dbf5b/raw/ConnectionTime.plugin.js"); | |
// Retrieve update from micelle's fork (This may have faster update) | |
// Huge thanks to micelle!! | |
ZeresPluginLibrary.PluginUpdater.checkForUpdate(this.getName(), this.getVersion(), "https://gist.github.com/micelle/b7c5000742ed89c7d56f06bda4bfed87/raw/ConnectionTime.plugin.js"); | |
} | |
*/ | |
start() | |
{ | |
sec = 0; | |
ConnectionTime_Interval = setInterval(Count, 1000); | |
} | |
stop() | |
{ | |
var connectionStatus = document.querySelectorAll("[class*=rtcConnectionStatusConnected-]")[0]; | |
if (connectionStatus != undefined) connectionStatus.innerText = document.documentElement.lang == "ja" ? "通話中" : "Voice Connected"; | |
clearInterval(ConnectionTime_Interval); | |
} | |
} | |
function Count() | |
{ | |
var connectionStatus = document.querySelectorAll("[class*=rtcConnectionStatusConnected-]")[0]; | |
if (connectionStatus == undefined) | |
{ | |
sec = 0; | |
} | |
else | |
{ | |
sec++; | |
connectionStatus.innerText = toHms(sec); | |
} | |
} | |
function toHms(t) | |
{ | |
var h = t / 3600 | 0; | |
var m = t % 3600 / 60 | 0; | |
var s = t % 60; | |
return document.documentElement.lang == "ja" ? h + "時間 " + padZero(m) + "分 " + padZero(s) + "秒" : h + "h " + padZero(m) + "m " + padZero(s) + "s" | |
} | |
function padZero(v) | |
{ | |
return v < 10 ? "0" + v : v; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
v1.3.0から自動更新機能を停止します。
もし動作しない場合はTwitter @katabame のDMにご報告をお願いします。