Quick Otonomai downloads

No more having to wait 5 seconds!

  1. // ==UserScript==
  2. // @name Quick Otonomai downloads
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description No more having to wait 5 seconds!
  6. // @author You
  7. // @match http://otonomai.me/forum/files/file/*
  8. // @grant none
  9. // ==/UserScript==
  10. /* jshint -W097 */
  11. 'use strict';
  12.  
  13. // Your code here...
  14.  
  15. // Get the parent
  16.  
  17. DownloadButton();
  18.  
  19. function DownloadButton(){
  20. var parent = $(".ipsToolList.ipsToolList_vertical.ipsClearfix");
  21. var link = $(".ipsButton.ipsButton_fullWidth.ipsButton_large.ipsButton_important").first().attr("href");
  22. console.log(link);
  23. var node = document.createElement("li");
  24. var linkNode = document.createElement("a");
  25. linkNode.classList.add("ipsButton","ipsButton_fullWidth","ipsButton_large","ipsButton_important");
  26. node.classList.add("ipsToolList","ipsToolList_vertical","ipsClearfix");
  27. linkNode.innerText = "Quick Download";
  28. linkNode.href = "#pass";
  29. node.appendChild(linkNode);
  30. linkNode.addEventListener("click",function(){
  31. $.get(link).then(function(data){
  32. var target = $(data).find(".ipsButton.ipsButton_primary.ipsButton_small").first().attr("href");
  33. var downloadLink = target.split(/&csrfKey/)[0];
  34. $.get(downloadLink).then(function(){
  35. linkNode.href = downloadLink;
  36. linkNode.innerText = "Ready to Download";
  37. })
  38. })
  39. })
  40.  
  41. parent.append(linkNode);
  42.  
  43. return ;
  44. }