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-01-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Chirbit.com Chirb.it Downloader
  3. // @description This is a simple script that shows you a direct link to audio file that you want to download.
  4. // @author q2p
  5. // @namespace q2p
  6. // @version 0.1
  7. // @include http://chirb.it/*
  8. // @include https://chirb.it/*
  9. // @include http://chirbit.com/*
  10. // @include https://chirbit.com/*
  11. // @include http://www.chirbit.com/*
  12. // @include https://www.chirbit.com/*
  13. // @grant none
  14. // @run-at document-end
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19. function make_link(name, title, fd) {
  20. const file = atob(fd.split('').reverse().join(''));
  21. const link_container = document.createElement("div");
  22. const link = document.createElement("a");
  23. link.href = file;
  24. link.download = name+" - "+title+".mp3";
  25. link.target = "_blank";
  26. link.textContent = "Download Link";
  27. link_container.appendChild(link);
  28. return link_container;
  29. }
  30. const full_name = document.getElementsByClassName("profile-fullname");
  31. const chirbit_username = document.getElementById("chirbit-username");
  32. if (full_name.length === 0 && chirbit_username !== null) {
  33. const name = chirbit_username.textContent;
  34. const title = document.getElementsByClassName("chirbit-title")[0].textContent;
  35. const wavholder = document.getElementsByClassName("wavholder")[0];
  36. const player_buttons = wavholder.getElementsByClassName("player-buttons")[0];
  37. for(let e of player_buttons.getElementsByTagName("i")) {
  38. if (e.id.startsWith("cplayer_") && e.dataset.fd) {
  39. let link = make_link(name, title, e.dataset.fd);
  40. link.classList.add("container");
  41. wavholder.parentElement.insertBefore(link, wavholder.nextSibling);
  42. break;
  43. }
  44. }
  45. } else if (full_name.length === 1 && chirbit_username === null) {
  46. const name = full_name[0];
  47. const cards = document.getElementsByClassName("media");
  48. for(let e of cards) {
  49. let media_body = e.getElementsByClassName("media-body")[0];
  50. let title = e.getElementsByClassName("truncate")[0].textContent;
  51. for(let i of e.getElementsByTagName("i")) {
  52. if (i.id.startsWith("cplayer_") && i.dataset.fd) {
  53. let link = make_link(name, title, i.dataset.fd);
  54. link.classList.add("media_row");
  55. let rows = media_body.getElementsByClassName("media-row");
  56. media_body.insertBefore(link, rows[rows.length-1]);
  57. break;
  58. }
  59. }
  60. }
  61. }
  62. })();