自动上传邀请码

直接上传邀请码!

目前為 2024-04-01 提交的版本,檢視 最新版本

// ==UserScript==
// @name         自动上传邀请码
// @namespace    https://linux.do
// @version      0.0.1
// @description  直接上传邀请码!
// @author       codecow
// @match        https://linux.do/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=linux.do
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/1.9.1/jquery.min.js
// @grant        none
// @license      MIT
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';
    let date = new Date();
    date.setDate(date.getDate() + 3);
    // 格式化日期和时间
    const year = date.getFullYear();
    const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 月份是从0开始的
    const day = date.getDate().toString().padStart(2, '0');
    const hours = date.getHours().toString().padStart(2, '0');
    const minutes = date.getMinutes().toString().padStart(2, '0');

    // 时区处理,这里简化处理为+08:00,具体时区可能需要动态获取或计算
    const timezone = '+08:00';

    // 构建expires_at参数值
    const expiresAt = `${year}-${month}-${day} ${hours}:${minutes}${timezone}`;
    let csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
    let headers = {
        "accept": "*/*",
        "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
        "cache-control": "no-cache",
        "content-type": "application/json; charset=utf-8",
        "discourse-logged-in": "true",
        "discourse-present": "true",
        "pragma": "no-cache",
        "x-csrf-token": csrfToken,
        "x-requested-with": "XMLHttpRequest"
    }
    let body = "max_redemptions_allowed=10&expires_at=" + encodeURIComponent(expiresAt)
    let flag = true;
    let invites = [];
    while(flag){
        fetch(`https://linux.do/invites`, {
            "headers": headers,
            "method": "POST",
            "mode": "cors",
            "credentials": "include",
            "body": body
        })
            .then(response => response.json())
            .then(data => {
            invites.push(data.link);
        })
            .catch((err) => {
            flag = false;
            console.log('Error:', err);
        });
    }
    // 上传邀请码
    const inviteLinksObject = invites.reduce((obj, link) => {
        obj[link] = link;
        return obj;
    }, {});
    fetch(`https://linuxdo-invites.speedcow.top/upload`, {
        "headers": "Content-Type: application/json",
        "method": "POST",
        "mode": "cors",
        "credentials": "include",
        "data": JSON.stringify(inviteLinksObject)
    })
        .then(response => response.json())
        .then(data => {
        console.log(data);
        })
        .catch((err) => {
        console.log('Error:', err);
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址