nexusmods skip countdown

no countdown & auto start download

  1. // ==UserScript==
  2. // @name nexusmods skip countdown
  3. // @namespace https://github.com/x94fujo6rpg/SomeTampermonkeyScripts
  4. // @version 0.1
  5. // @description no countdown & auto start download
  6. // @author x94fujo6
  7. // @match https://www.nexusmods.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14. window.onload = checkURL();
  15.  
  16. function checkURL() {
  17. // https://www.nexusmods.com/*/mods/*tab=files&file_id=*
  18. if (window.location.href.match(/www\.nexusmods\.com\/.*\/mods\/\d+\?tab=files&file_id=\d+/)) direct_download();
  19. }
  20.  
  21. function direct_download() {
  22. let game_id = window.current_game_id;
  23. let file_id = window.location.href.match(/file_id=(\d+)/);
  24. if (!game_id) return console.log("game_id not found");
  25. if (!file_id) return console.log("file_id not found");
  26. file_id = file_id[1];
  27.  
  28. $('.subheader, .table').hide();
  29. $('.donation-wrapper').show();
  30.  
  31. $.ajax({
  32. type: "POST",
  33. url: "/Core/Libs/Common/Managers/Downloads?GenerateDownloadUrl",
  34. data: {
  35. fid: file_id,
  36. game_id: game_id,
  37. },
  38. success: function (data) {
  39. if (data && data.url) {
  40. console.log('Success');
  41. window.location.href = data.url;
  42. $('.donation-wrapper > p').html(`<p>Your download has started</p><p>If you are having trouble, <a href="${data.url}">click here</a> to download manually</p>`);
  43. } else {
  44. setError();
  45. }
  46. },
  47. error: function () {
  48. setError();
  49. }
  50. });
  51. }
  52.  
  53. function setError() {
  54. console.log('An error occurred');
  55. $('.donation-wrapper > p').html('<p>Unfortunately an error occurred while downloading this file</p><p>Please try again later or contact support</p>');
  56. }
  57. })();