1Fichier Redirect to FastDebrid

Save 1fichier link, redirect to FastDebrid and autofill the link.

  1. // ==UserScript==
  2. // @name 1Fichier Redirect to FastDebrid
  3. // @namespace https://violentmonkey.github.io/
  4. // @version 1.4
  5. // @description Save 1fichier link, redirect to FastDebrid and autofill the link.
  6. // @author Rust1667
  7. // @match https://1fichier.com/*
  8. // @match https://fastdebrid.com/*
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @grant GM_deleteValue
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Function to check if the Cloudflare captcha is solved
  18. function checkCloudflareCaptchaSolved() {
  19. if (document.querySelector('.cf-turnstile') || document.querySelector('#captcha-turnstile')) {
  20. return unsafeWindow.turnstile && unsafeWindow.turnstile.getResponse().length !== 0;
  21. }
  22. return true;
  23. }
  24.  
  25. // Wait for the page to load fully
  26. window.addEventListener('load', function() {
  27.  
  28. const currentUrl = window.location.href;
  29.  
  30. // On 1fichier page
  31. if (currentUrl.includes('1fichier.com') && !currentUrl.endsWith('=') && !document.body.innerText.includes("file has been deleted") && !document.body.innerText.includes("automatically deleted")) {
  32. GM_setValue('saved1FichierLink', currentUrl);
  33. window.location.assign('https://fastdebrid.com/');
  34.  
  35. // On FastDebrid page
  36. } else if (currentUrl === 'https://fastdebrid.com/') {
  37.  
  38. const fichierOption = document.querySelector('[data-name="1fichier"]');
  39. if (fichierOption) {
  40. fichierOption.click();
  41. }
  42.  
  43. function fillForm() {
  44. const savedLink = GM_getValue('saved1FichierLink');
  45. if (savedLink) {
  46. const inputField = document.querySelector('#link');
  47. if (inputField) {
  48. inputField.value = savedLink;
  49. GM_deleteValue('saved1FichierLink');
  50. }
  51. }
  52. }
  53.  
  54. function clickDebridButton() {
  55. const debridButton = document.querySelector('button.btn-primary');
  56. if (debridButton && debridButton.innerText.includes('Debrid my link')) {
  57. debridButton.click();
  58. }
  59. }
  60.  
  61. // Wait for cloudflare captcha to be solved to fill the form and click the button
  62. let captchaCheckInterval = setInterval(() => {
  63. if (checkCloudflareCaptchaSolved()) {
  64. clearInterval(captchaCheckInterval);
  65. fillForm();
  66. clickDebridButton();
  67. }
  68. }, 1000);
  69.  
  70.  
  71.  
  72. // On fastdebrid page with link ready for download
  73. } else if (/https:\/\/fastdebrid.com\/.*/.test(currentUrl)) {
  74. const shortlinkElement = document.querySelector('a.btn-primary.mx-1')
  75. const dlLinkElement = document.querySelector('a.btn-success.mx-1')
  76. if (shortlinkElement) {window.location.assign(shortlinkElement.href);}
  77. //else if (dlLinkElement) {window.location.assign(dlLinkElement.href);}
  78. }
  79. });
  80.  
  81. })();