SC: get artwork url

click artwork to copy original size URL to clipboard

目前為 2023-04-22 提交的版本,檢視 最新版本

// ==UserScript==
// @name        SC: get artwork url
// @namespace   Violentmonkey Scripts
// @match       https://soundcloud.com/*
// @grant       none
// @version     0.1.5
// @author      -
// @description click artwork to copy original size URL to clipboard
// @license     GPLv3
// ==/UserScript==

(function() {
  'use strict';

  // config
  const runEverywhere = true;
  const doAvatars     = false;
  // end config


  document.querySelector('body').addEventListener('click', checkImage, true);

  function checkImage(evt) {
    const t = evt.target;
    if (t.nodeName == 'SPAN' && t.classList.contains('sc-artwork') ) {
      var url = t.style.backgroundImage
                    .split('"')[1]
                    .replace(/-t\d{2,4}x\d{2,4}\.jpg/, '-original.jpg');
      console.log(url);
      if (!url) {
        console.log('error finding image url');
        return;
      }
      if (!runEverywhere && !document.querySelector('div.l-listen-hero') ) {
         return;
      }
      if (!doAvatars && url.includes('/avatars-') ) {
        return;
      }

      evt.preventDefault();
      evt.stopPropagation();
      //navigator.clipboard.writeText(url);
      window.open(url);
    }
   }

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址