Chirbit.com Chirb.it Downloader

This is a simple script that shows you a direct link to audio file that you want to download.

目前為 2021-03-20 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Chirbit.com Chirb.it Downloader
// @description This is a simple script that shows you a direct link to audio file that you want to download.
// @license     Creative Commons Zero v1.0 Universal
// @supportURL  https://github.com/q2p/Chirbit-Link-Exporter
// @author      q2p
// @namespace   q2p
// @version     0.3
// @include     http://chirb.it/*
// @include     https://chirb.it/*
// @include     http://chirbit.com/*
// @include     https://chirbit.com/*
// @include     http://www.chirbit.com/*
// @include     https://www.chirbit.com/*
// @grant       none
// @run-at      document-end
// ==/UserScript==

(function() {
	'use strict';
	function make_link(name, title, fd) {
		const file = atob(fd.split('').reverse().join(''));
		const link_container = document.createElement("div");
		const link = document.createElement("a");
		link.href = file;
		link.download = name+" - "+title+".mp3";
		link.target = "_blank";
		link.textContent = "Download Link";
		link_container.appendChild(link);
		return link_container;
	}
	const full_name = document.getElementsByClassName("profile-fullname");
	const chirbit_username = document.getElementById("chirbit-username");
	if (full_name.length === 0 && chirbit_username !== null) {
		const name = chirbit_username.textContent;
		const title = document.getElementsByClassName("chirbit-title")[0].textContent;
		const wavholder = document.getElementsByClassName("wavholder")[0];
		const player_buttons = wavholder.getElementsByClassName("player-buttons")[0];
		for(let e of player_buttons.getElementsByTagName("i")) {
			if (e.id.startsWith("cplayer_") && e.dataset.fd) {
				let link = make_link(name, title, e.dataset.fd);
				link.classList.add("container");
				wavholder.parentElement.insertBefore(link, wavholder.nextSibling);
				break;
			}
		}
	} else if (full_name.length === 1 && chirbit_username === null) {
		const name = full_name[0];
		const cards = document.getElementsByClassName("media");
		for(let e of cards) {
			let media_body = e.getElementsByClassName("media-body")[0];
			let title = e.getElementsByClassName("truncate")[0].textContent;
			for(let i of e.getElementsByTagName("i")) {
				if (i.id.startsWith("cplayer_") && i.dataset.fd) {
					let link = make_link(name, title, i.dataset.fd);
					link.classList.add("media_row");
					let rows = media_body.getElementsByClassName("media-row");
					media_body.insertBefore(link, rows[rows.length-1]);
					break;
				}
			}
		}
	}
})();