Download Links for soundgasm.net

show source mp4 link for soundgasm site

当前为 2016-05-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Download Links for soundgasm.net
  3. // @namespace https://chrome.google.com/webstore/detail/download-links-for-soundg/bchfdaafdfgamfakeigoopdkpkpjocmc
  4. // @version 0.0.4
  5. // @description show source mp4 link for soundgasm site
  6. // @match https://soundgasm.net/u/*/*
  7. // @copyright Don
  8. // ==/UserScript==
  9.  
  10. //copy what Don did so well and updated to website and get it into a script.
  11. //Thank you Don I can't reach you but if you want me to take this down I'll be glad to
  12.  
  13. (function () {
  14. var playerDiv = document.getElementById("jquery_jplayer_1");
  15. if (!playerDiv) {
  16. return;
  17. }
  18.  
  19. function username () {
  20. var match = window.location.pathname.match(/\/u\/(.+)\/.+/);
  21. if (!match) {
  22. return "";
  23. }
  24. return match[1];
  25. }
  26.  
  27. function title () {
  28. var e = document.querySelector(".jp-title").innerHTML;
  29. return e;
  30. }
  31.  
  32.  
  33. function filename (href) {
  34. var ext = href.match(/.+\.(.+)$/);
  35. if (!ext) {
  36. return username() + " - " + title();
  37. }
  38. return username() + " - " + title() + "." + ext[1];
  39. }
  40.  
  41. var interval = setInterval(function () {
  42. var audio = document.getElementsByTagName("audio")[0];
  43. if (!audio && !audio.src) {
  44. return;
  45. }
  46. clearInterval(interval);
  47. var ul = document.querySelector(".jp-description ul");
  48. if (!ul) {
  49. return;
  50. }
  51. var li = document.createElement("li");
  52. var a = document.createElement("a");
  53. a.href = audio.src;
  54. a.innerText = "download";
  55. a.download = filename(audio.src);
  56. li.appendChild(a);
  57. ul.appendChild(li);
  58. }, 1000);
  59. })();