genius-date

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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