genius-date

script to inject today's date when transcribing a new song

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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);
})();