LastFM: History Cleanup

You can easily remove unwanted plays from your listening history

目前為 2023-11-13 提交的版本,檢視 最新版本

// ==UserScript==
// @name                  LastFM: History Cleanup
// @name:ru               LastFM: Очистка истории
// @description           You can easily remove unwanted plays from your listening history
// @description:ru        Позволяет легко удалять нежелательные воспроизведения из истории прослушивания
// @namespace             lastfm-chartlist-cleanup
// @version               0.1.1
// @license               WTFPL
// @author                askornot
// @match                 https://www.last.fm/*/user/*
// @grant                 unsafeWindow
// @homepageURL           https://gf.qytechs.cn/ru/scripts/479773-lastfm-history-cleanup/
// @supportURL            https://gf.qytechs.cn/ru/scripts/479773-lastfm-history-cleanup/feedback
// @compatible            chrome  Violentmonkey 2.16.0
// @compatible            firefox Violentmonkey 2.16.0
// @compatible            firefox Greasemonkey 4.11
// ==/UserScript==

(function (W, D, O, G, F) {
  'use strict';

  const clone = function (row) {
    const love = row.querySelector('.chartlist-loved div');
    const remove = row.querySelector('li:nth-child(7) form');
    if (love === null || remove === null) return;
    const a = love.cloneNode(true);
    const b = remove.cloneNode(true);
    const text = b.lastElementChild.textContent;
    if (text) {
      b.lastElementChild.title = text.trim();
      b.lastElementChild.textContent = '';
    }
    b.lastElementChild.style.background = 'transparent';
    while (a.attributes.length > 0) {
      a.removeAttribute(a.attributes[0].name);
    }
    a.replaceChild(b, a.lastElementChild);
    row.insertBefore(a, row.lastElementChild);
  };

  (function (target, proto, prop, descriptor) {
    const content = {
      'text/html; charset=utf-8': function (id, fn) {
        return O.assign(D.createElement('script'), {
          id: id,
          textContent: `document.querySelectorAll('.chartlist-row').forEach(Function('row', \`return ${fn.toString()}\`)());
          document.scripts.namedItem(${id}).remove();`,
        }).outerHTML;
      },
    };

    const responseText = O[G](W[target][proto], prop);
    O[F](W[target][proto], prop, {
      get() {
        const res = responseText[descriptor].apply(this, arguments);
        if (this.readyState === target.DONE) {
          const type = this.getResponseHeader('content-type');
          const fn = content[type];
          if (fn) {
            const outer = fn(Math.random(), clone);
            return res + outer;
          }
        }
        return res;
      },
    });
  })('XMLHttpRequest', 'prototype', 'responseText', 'get');

  D.querySelectorAll('.chartlist-row').forEach(clone);
})(
  unsafeWindow || window,
  document,
  Object,
  'getOwnPropertyDescriptor',
  'defineProperty',
);

QingJ © 2025

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