script to inject today's date when transcribing a new song
// ==UserScript==
// @name genius-date
// @description script to inject today's date when transcribing a new song
// @namespace http://tampermonkey.net/
// @license MIT
// @version 2.0.0
// @description A simple example userscript
// @author solomoncyj
// @match https://genius.com/new
// @grant none
// ==/UserScript==
const month = ["January","February","March","April","May","June","July","August","September","October","November","December"];
var event = new Event('change');
function setNativeValue(element, value) {
let lastValue = element.value;
element.value = value;
let event = new Event("input", { target: element, bubbles: true });
// React 15
event.simulated = true;
// React 16
let tracker = element._valueTracker;
if (tracker) {
tracker.setValue(lastValue);
}
element.dispatchEvent(event);
}
function inject()
{
const today = new Date(Date.now());
setNativeValue(document.querySelector('input[aria-label="Release Day"]'), today.getDate())
setNativeValue(document.querySelector('input[aria-label="Release Month"]'), month[today.getMonth()])
setNativeValue(document.querySelector('input[aria-label="Release Year"]'), today.getFullYear())
}
(function() {
'use strict';
let btn = document.createElement("button");
btn.type = "button"
btn.onclick = () => {
inject()
};
const info = document.createTextNode("Today");
var xpath = "//span[text()='Release Date']";
var div = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
div.appendChild(btn);
btn.appendChild(info);
})();