Onlyfans Coomer.su

Adds a link to the user's profile in the specified menu

当前为 2024-04-28 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Onlyfans Coomer.su
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds a link to the user's profile in the specified menu
// @author       You
// @match        https://onlyfans.com/*
// @grant        none
// @license      Unlicense
// ==/UserScript==

(function() {
    'use strict';

    function getUsernameFromUrl() {
        const urlParts = window.location.pathname.split('/');
        const username = urlParts[1];
        return username;
    }

    function fetchUserProfile(username, retryCount = 0) {
        const apiUrl = `https://coomer.su/api/v1/onlyfans/user/${username}/profile`;

        fetch(apiUrl)
            .then(response => {
                if (!response.ok) {
                    if (response.status === 404) {
                        console.log(`User ${username} not found`);
                    } else {
                        throw new Error('Network response was not ok');
                    }
                }
                return response.json();
            })
            .then(data => {
                if (data) {
                    const profileUrl = `https://coomer.su/onlyfans/user/${username}`;
                    const menuElement = document.querySelector('.l-header__menu.m-native-custom-scrollbar.m-scrollbar-y.m-invisible-scrollbar');
                        const aElement = document.createElement('a');
                        aElement.setAttribute('href', profileUrl);
                        aElement.textContent = 'Coomer.su';
                        menuElement.appendChild(aElement);
                }
            })
            .catch(error => {
                if (retryCount < 5) {
                    console.log(`Retrying... Attempt ${retryCount + 1}`);
                    setTimeout(() => fetchUserProfile(username, retryCount + 1), 1000);
                } else {
                    console.error('Error fetching data:', error);
                }
            });
    }

    const username = getUsernameFromUrl();
    fetchUserProfile(username, 0);

})();