由于freenom加上了人机验证,原来的自动续订工具不再适合。
故编写此脚本用于快速批量续订freenom域名,通过用户手动操作来通过任何种类的人机验证。
使用此油猴脚本前,记得先在浏览器中创建隐私标签页,并允许油猴访问隐私标签页。
脚本内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | // ==UserScript== // @name Freenom Auto Renewal Period // @namespace http://tampermonkey.net/ // @version 1.0 // @description Automatically set the renewal period to 12 Months @ FREE on freenom.com domains page, click the order button, renew domains when eligible, and close the page after completing an order. // @author You // @match https://*.freenom.com/* // @run-at document-end // @grant none // ==/UserScript== (function() { 'use strict'; // Function to set the selected option in the renewal period select dropdown function setRenewalPeriod() { const renewalSelect = document.querySelector("select.pullRight[name^='renewalperiod']"); if (!renewalSelect) { console.log("Renewal period select not found."); return false; } const renewalOptions = renewalSelect.options; for (let i = 0; i < renewalOptions.length; i++) { const option = renewalOptions[i]; if (option.text.includes('12 Months @ FREE')) { option.selected = true; console.log("Renewal period set to 12 Months @ FREE."); return true; } } return false; } // Function to simulate button click function clickOrderButton() { const orderButton = document.getElementById("formSubmit"); if (orderButton) { orderButton.click(); console.log("Order button clicked."); } else { console.log("Order button not found."); } } // Function to check if the current URL is cart.php?a=complete and close the tab if order is completed function checkOrderCompleted() { const currentUrl = "https://my.freenom.com/cart.php?a=complete"; if (window.location.href === currentUrl) { const orderNumberText = document.querySelector("strong"); if (orderNumberText && orderNumberText.textContent.includes("Your Order Number is:")) { console.log("Order completed. Closing the tab..."); window.close(); } } } // Function to check and renew eligible domains function checkAndRenewDomains() { const renewalRows = document.querySelectorAll("table tbody tr"); if (!renewalRows) { console.log("Renewal rows not found."); return; } for (const row of renewalRows) { const renewalStatus = row.querySelector("td span.textgreen"); if (renewalStatus && renewalStatus.textContent.trim() === "Renewable") { const renewButton = row.querySelector("td a.smallBtn.greyBtn.pullRight"); if (renewButton) { const domainId = renewButton.href.match(/domain=(\d+)/); if (domainId && domainId[1]) { // Open the link in a new tab window.open(renewButton.href, "_blank"); console.log("Renew link opened in a new tab for domain ID:", domainId[1]); } } } } } // Wait for the page to load completely before modifying the select element, clicking the button, and checking/renewing domains window.addEventListener('load', () => { // Check if the URL is exactly https://my.freenom.com/domains.php?a=renewals if (window.location.href === "https://my.freenom.com/domains.php?a=renewals") { checkAndRenewDomains(); } else if (window.location.href.includes("/domains.php")) { if (setRenewalPeriod()) { clickOrderButton(); } } // Check if the current URL is cart.php?a=complete and close the tab if order is completed checkOrderCompleted(); }); })(); |
发表回复