linuxdo生日图标

linuxdo 生日图标

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

// ==UserScript==
// @name          linuxdo生日图标
// @namespace    https://yby6.com
// @version     1.1
// @description   linuxdo 生日图标
// @author       杨不易呀
// @match        https://linux.do/*
// @match     *://*.linux.do
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @antifeature referral-link 【应GreasyFork代码规范要求:含有优惠券查询功能的脚本必须添加此提示!在此感谢大家的理解...】
// @run-at document-start
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
       (function () {

                setTimeout(() => {

    // Your code here...
    // 获取当前登录(不可用)的 名称
    // window.location.href
    // 获取当前URL

const givenUrl = window.location.href;
// 查找"/u/"在URL中的位置
const startIndex = givenUrl.indexOf('/u/');
// 如果找到了"/u/"
if (startIndex !== -1) {
    // 计算"/u/"后面字符的起始位置
    const start = startIndex + 3;

    // 查找下一个"/"的位置,作为结束位置
    const endIndex = givenUrl.indexOf('/', start);

    // 提取"/u/"和下一个"/"之间的字符
    let result;
    if (endIndex !== -1) {
        result = givenUrl.substring(start, endIndex);
    } else {
        // 如果没有找到下一个"/",则提取到URL的末尾
        result = givenUrl.substring(start);
    }



let today = new Date();
let todayFormated = `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`;
let csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
fetch(`https://linux.do/u/${result}.json`, {
  "headers": {
    "accept": "*/*",
    "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
    "cache-control": "no-cache",
    "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
    "discourse-logged-in": "true",
    "discourse-present": "true",
    "pragma": "no-cache",
    "x-csrf-token": csrfToken,
    "x-requested-with": "XMLHttpRequest"
  },
  "body": `date_of_birth=${todayFormated}`,
  "method": "PUT",
  "mode": "cors",
  "credentials": "include"
});

    console.log(result); // 打印结果
    console.log(result); // 打印结果
    console.log(result); // 打印结果
} else {
    // 如果URL中没有"/u/"
    console.log("The URL does not contain '/u/'.");
}

                      },3000)

})();

})();

QingJ © 2025

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