Nexus No Wait

Download from Nexusmods.com without wait and redirect (support Manual/Vortex)

目前為 2020-01-23 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Nexus No Wait
  3. // @description Download from Nexusmods.com without wait and redirect (support Manual/Vortex)
  4. // @namespace NexusNoWait
  5. // @include https://www.nexusmods.com/*/mods/*
  6. // @run-at document-idle
  7. // @version 1.3
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
  9. // ==/UserScript==
  10.  
  11.  
  12. $(document).on('click', '.btn', function(event) {
  13.  
  14. var href = $(this).attr('href');
  15. if (~href.indexOf("file_id")) {
  16. event.preventDefault();
  17. var button = $(this);
  18.  
  19. button.css("color", "yellow");
  20. button.text('WAIT');
  21.  
  22. var game_id = document.getElementById("section").dataset.gameId;
  23. var search_params = new URLSearchParams(href);
  24. var file_id = search_params.get("file_id");
  25.  
  26. if (!~href.indexOf("nmm")) {
  27. $.ajax({
  28. type: "POST",
  29. url: "/Core/Libs/Common/Managers/Downloads?GenerateDownloadUrl",
  30. data: {
  31. fid: file_id,
  32. game_id: game_id,
  33. },
  34. success: function(data) {
  35. if (data && data.url) {
  36. console.log('Success');
  37. window.location.href = data.url;
  38. btnSuccess(button);
  39. } else {
  40. btnError(button);
  41. }
  42. },
  43. error: function() {
  44. btnError(button);
  45. }
  46. });
  47. } else {
  48. $.ajax({
  49. type: "GET",
  50. url: href,
  51. success: function(data) {
  52. var slow = $(data).find('#slowDownloadButton');
  53. var downloadUrl = slow.data('download-url');
  54. document.location.href = downloadUrl;
  55. btnSuccess(button);
  56. },
  57. error: function(ajaxContext) {
  58. console.log(ajaxContext.responseText);
  59. btnError(button);
  60. }
  61. });
  62. }
  63. }
  64. var popup = $(this).parent();
  65. if (popup.hasClass('popup')) {
  66. popup.children("button").click();
  67. }
  68. });
  69.  
  70. function btnError(button) {
  71. button.css("color", "red");
  72. button.text('ERROR');
  73. }
  74.  
  75. function btnSuccess(button) {
  76. button.css("color", "green");
  77. button.text('LOADING');
  78. }