Adds some useful UIs for copying timestamps.
Last active
December 21, 2021 23:07
-
-
Save overestimate/fbeeed2f5130596bf71c8daf86e5524d to your computer and use it in GitHub Desktop.
NameMC Info Copy Script
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
// ==UserScript== | |
// @name NameMC Info Copy | |
// @namespace http://overestimate.ninja/ | |
// @version 0.4.2 | |
// @description Gets timestamp and name info for quick sniper usage. | |
// @author overestimate | |
// @match https://namemc.com/search?q=* | |
// @match https://namemc.com/minecraft-names* | |
// @icon https://www.google.com/s2/favicons?domain=namemc.com | |
// @grant none | |
// @updateURL https://gist.github.com/overestimate/fbeeed2f5130596bf71c8daf86e5524d/raw/NameMC%20Info.user.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const listTitle = "Minecraft Names | NameMC" | |
const name = $($($($($('main').children()[0]).children()[1]).children()[0]).children()[0]).children()[0].innerHTML | |
const time = Math.trunc(Date.parse($($('time')[0]).attr('datetime')) / 1000) | |
const rfcTime = $($('time')[0]).attr('datetime') | |
const info = name + '-' + time | |
const ckmInfo = `{"UNIX": ${time}}` | |
const ssInfo = `{"droptime": "${rfcTime}", "unix": ${time}, "name": "${name}"}` | |
const menuText = ` | |
<div class="card bg-primary text-white p-1" style="margin:12px 0;"> | |
<center><h6>NameMC Info Copy</h6> | |
<b>Droptime compatibility mode</b></center> | |
<select class="form-control" id="compatModeForDroptime"> | |
<option>Default (name-time)</option> | |
<option>CKM ({"UNIX": time, "name": name})</option> | |
<option>star.shopping ({"droptime": rfcTime, "unix": time, "username": name}</option> | |
</select> | |
<button id="infoBtn" onclick="getInfo()" type="button" class="btn btn-secondary" style="margin: 8px 0;">Copy Info</button> | |
` | |
const getAllBtnText = `<button id="copyBtn" onclick="getInfo()" type="button" style="margin: 14px 33.3333%; width: 33.333%;" class="btn btn-secondary navbar-btn">Copy All</button>` | |
if (document.title == listTitle) { | |
$($($($('main')[0]).children()[0]).children()[1]).append($.parseHTML(getAllBtnText)) | |
window.getInfo = function() { | |
var nameStampList = [] | |
var isEven = true | |
var nameTmp = "" | |
var unix = "" | |
var rfc = "" | |
$($($($($($($($('main')[0]).children()[0]).children()[3]).children()[0]).children()[0]).children()[1]).children()).each((i, v) => { | |
if (isEven) { | |
nameTmp = $($($(v).children()[0]).children()[0]).text() | |
} else { | |
rfc = $($($(v).children()[0]).children()[0]).attr('datetime') | |
unix = Math.trunc(Date.parse(rfc) / 1000) | |
var tmp = { "name": nameTmp, "datetime": rfc, "unix": unix } | |
nameStampList.push(tmp) | |
nameTmp = "" | |
unix = "" | |
rfc = "" | |
} | |
isEven = !isEven | |
}) | |
var btn = $('#copyBtn') | |
navigator.clipboard.writeText(JSON.stringify(nameStampList, undefined, 2)) | |
btn.text('Copied.') | |
setTimeout(() => { | |
btn.text('Copy All') | |
}, 1500) | |
} | |
} else { | |
$($($($($($('main')[0]).children()[0]).children()[1]).children()[0]).children()[0]).after($.parseHTML(menuText)) | |
const copyButton = $("#infoBtn") | |
window.setCompatMode = function() { | |
window.compatModeForDrop = "default" | |
var mode = $('#compatModeForDroptime').find(":selected").text() | |
switch (mode) { | |
case 'Default (name-time)': window.compatModeForDrop = "default"; break | |
case 'CKM ({"UNIX": time, "name": name})': window.compatModeForDrop = "ckm"; break | |
case 'star.shopping ({"droptime": rfcTime, "unix": time, "username": name}': window.compatModeForDrop = "ss"; break | |
default: window.compatModeForDrop = "default" | |
} | |
} | |
window.getInfo = function() { | |
setCompatMode() | |
switch (window.compatModeForDrop) { | |
case 'ckm': navigator.clipboard.writeText(ckmInfo); break | |
case 'ss': navigator.clipboard.writeText(ssInfo); break | |
default: navigator.clipboard.writeText(info) | |
} | |
copyButton.text('Copied.') | |
setTimeout(() => { | |
copyButton.text('Copy Info') | |
}, 1500) | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment