/* eslint-disable no-extra-semi */ // ==UserScript== // @name 9ku.com 九酷音乐下载 // @namespace https://greasyfork.org/zh-CN/users/812943 // @version 0.0.4 // @description 九酷音乐下载工具,一键另存下载MP3文件,一键复制歌曲文件名 // @author gafish // @match https://www.9ku.com/play/*.htm // @icon https://www.google.com/s2/favicons?domain=9ku.com // @license MIT // @require https://cdn.jsdelivr.net/npm/copy-to-clipboard@3.3.1/example/index.js // @grant none // ==/UserScript== ;(function (jQuery, copyToClipboard) { 'use strict' const box = jQuery('.ppBox') const feifa = jQuery('#feifa') const downloadedKey = 'chrome_plugin_downloaded' let musicInfo const init = () => { const { singer, musicname, song_id, meida } = window const { mp3 } = meida musicInfo = { singer, musicName: musicname, songID: song_id, mp3URL: mp3, downloadFileName: `${singer} - ${musicname}.mp3`, } if (!box[0]) return box.css({ height: 340 }) addDownloadButton() addMp3FileName() hidePalylistAd() const downloaded = getDownloaded() if (downloaded.includes(musicInfo.songID)) { addDownloadedTag() } } const getDownloaded = () => { const downloaded = window.localStorage[downloadedKey] || '[]' const downloadedArr = JSON.parse(downloaded) return downloadedArr } const addDownloadButton = () => { if (!box || !musicInfo) return const downloadBtn = jQuery(` 右键另存MP3文件 `) downloadBtn .css({ display: 'block', backgroundColor: '#f00', color: '#fff', padding: '5px 10px', borderRadius: 5, margin: 10, textAlign: 'center', height: 30, lineHeight: '30px', }) .contextmenu(() => { const downloaded = getDownloaded() if (!downloaded.includes(musicInfo.songID)) { downloaded.push(musicInfo.songID) window.localStorage[downloadedKey] = JSON.stringify(downloaded) } addDownloadedTag() }) box.append(downloadBtn) } const addMp3FileName = () => { if (!box || !musicInfo) return const fileNameContaner = jQuery(`