Skip to content

Instantly share code, notes, and snippets.

@katabame
Last active August 10, 2021 17:26
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save katabame/ef65c6379c8d50af8702c5932c6dbf5b to your computer and use it in GitHub Desktop.
Save katabame/ef65c6379c8d50af8702c5932c6dbf5b to your computer and use it in GitHub Desktop.
VCに接続されている時間を表示するDiscordプラグイン | Discord plugin that displays how long connected to VC
//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;
}
@katabame
Copy link
Author

katabame commented Aug 5, 2019

Merged some patches from @Micelle's fork
https://gist.github.com/micelle/b7c5000742ed89c7d56f06bda4bfed87/c52998a517cc7eca6b1a260ceb95fb14d8826dd2

From v1.2.0, this plugin will also check updates from micelle's fork
Huge thanks to micelle for fixing this plugin.


@Micelleさんのforkからいくつかの修正を取り込みました
https://gist.github.com/micelle/b7c5000742ed89c7d56f06bda4bfed87/c52998a517cc7eca6b1a260ceb95fb14d8826dd2

v1.2.0以降、micelleさんのforkからも更新を確認するようになります
修正していただいたmicelleさんに多大なる感謝を!

@katabame
Copy link
Author

katabame commented Aug 2, 2021

v1.3.0から自動更新機能を停止します。

もし動作しない場合はTwitter @katabame のDMにご報告をお願いします。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment