twitch-clips-datetime.user.js
· 1.3 KiB · JavaScript
Raw
// ==UserScript==
// @name Twitch Clips - Show date & time
// @version 0.1
// @description Displays the actual date & time of when a clip was created, instead of the useless "xxx days/months/weeks ago"
// @author Decicus
// @match https://clips.twitch.tv/*
// ==/UserScript==
(async function() {
'use strict';
const slug = window.location.href.match(/https\:\/\/clips\.twitch\.tv\/([A-z0-9]+)/m)[1];
if (!slug) {
return;
}
const response = await fetch(`https://api.twitch.tv/kraken/clips/${slug}`, {
headers: {
Accept: 'application/vnd.twitchtv.v5+json',
'Client-ID': 'zs377ogpzz01ogfx26pvbddx9jodg1',
},
});
const data = await response.json();
if (!data.created_at) {
return;
}
const created = new Date(data.created_at);
const dateAndTime = created.toLocaleString();
const box = document.getElementsByClassName('clips-chat-info tw-align-items-start tw-flex tw-flex-column tw-flex-grow-1 tw-flex-shrink-1 tw-justify-content-center tw-lg-mg-y-2 tw-mg-t-1');
const child = document.createElement('span');
child.innerHTML = `Clip created:<br />${dateAndTime}`;
const parentElement = document.createElement('div');
parentElement.append(child);
box[0].appendChild(parentElement);
})();
| 1 | // ==UserScript== |
| 2 | // @name Twitch Clips - Show date & time |
| 3 | // @version 0.1 |
| 4 | // @description Displays the actual date & time of when a clip was created, instead of the useless "xxx days/months/weeks ago" |
| 5 | // @author Decicus |
| 6 | // @match https://clips.twitch.tv/* |
| 7 | // ==/UserScript== |
| 8 | |
| 9 | (async function() { |
| 10 | 'use strict'; |
| 11 | |
| 12 | const slug = window.location.href.match(/https\:\/\/clips\.twitch\.tv\/([A-z0-9]+)/m)[1]; |
| 13 | if (!slug) { |
| 14 | return; |
| 15 | } |
| 16 | |
| 17 | const response = await fetch(`https://api.twitch.tv/kraken/clips/${slug}`, { |
| 18 | headers: { |
| 19 | Accept: 'application/vnd.twitchtv.v5+json', |
| 20 | 'Client-ID': 'zs377ogpzz01ogfx26pvbddx9jodg1', |
| 21 | }, |
| 22 | }); |
| 23 | |
| 24 | const data = await response.json(); |
| 25 | if (!data.created_at) { |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | const created = new Date(data.created_at); |
| 30 | const dateAndTime = created.toLocaleString(); |
| 31 | |
| 32 | const box = document.getElementsByClassName('clips-chat-info tw-align-items-start tw-flex tw-flex-column tw-flex-grow-1 tw-flex-shrink-1 tw-justify-content-center tw-lg-mg-y-2 tw-mg-t-1'); |
| 33 | |
| 34 | const child = document.createElement('span'); |
| 35 | child.innerHTML = `Clip created:<br />${dateAndTime}`; |
| 36 | |
| 37 | const parentElement = document.createElement('div'); |
| 38 | parentElement.append(child); |
| 39 | |
| 40 | box[0].appendChild(parentElement); |
| 41 | })(); |