Greasy Fork

Greasy Fork is available in English.

Soundcloud Precise Date

A script to replace relative dates with exact dates (e.g track upload date, comment publication date).

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Soundcloud Precise Date
// @namespace    Violentmonkey Scripts
// @match        https://soundcloud.com/*
// @grant        none
// @version      2.0
// @author       bye-csavier (https://github.com/bye-csavier)
// @run-at       document-end
// @description  A script to replace relative dates with exact dates (e.g track upload date, comment publication date).
// @license      GNU GPLv3
// ==/UserScript==

function setRealDate(relDate){
  if(relDate.dataset.xjsPreciseSoundCloudDate) return;
  let realDate = relDate.getAttribute("title")
  relDate.children[1].innerText = realDate; //may changed based on soundcloud comoponents strcture
  relDate.dataset.xjsPreciseSoundCloudDate = true;
}

function handleAllRelativeTimes(){
  let trackDates = document.querySelectorAll("time.relativeTime");
  for (let i = 0, len = trackDates.length; i < len; ++i) {
    setRealDate(trackDates[i])
  }
}

handleAllRelativeTimes(); //If the content is already loaded, somehow


let idleDone = false;
/*
    I guess soundcloud loads everything after the DOMContentLoaded event, trough scripts. Therefore I need to observe for every mutation on the body :(
    Still, the mutation is used to replace the new content the user loads so +1 for mutation observer.

    It may be possible to stop it after a while it gets not called and trigger the mec
*/
new MutationObserver((mutations, observer)=>{
  handleAllRelativeTimes();
  if(!idleDone){
    idleDone = true;
    observer.disconnect();
    observer.observe(document.getElementById("content"), {subtree:true, childList:true})
  }
}).observe(document.body, {subtree:true, childList:true})