Kogama Logout Button

Adds a logout button for Kogama and checks for saved password

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Kogama Logout Button
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds a logout button for Kogama and checks for saved password
// @author       Your Name
// @match        *://www.kogama.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Create a logout button
    const logoutButton = document.createElement('button');
    logoutButton.innerText = 'Logout';
    logoutButton.style.position = 'fixed';
    logoutButton.style.top = '10px';
    logoutButton.style.right = '10px';
    logoutButton.style.zIndex = '1000';
    logoutButton.style.padding = '10px';
    logoutButton.style.backgroundColor = '#ff0000';
    logoutButton.style.color = '#ffffff';
    logoutButton.style.border = 'none';
    logoutButton.style.borderRadius = '5px';
    logoutButton.style.cursor = 'pointer';

    document.body.appendChild(logoutButton);

    // Check if password is saved
    const isPasswordSaved = () => {
        const passwordField = document.querySelector('input[type="password"]');
        return passwordField && passwordField.value.length > 0;
    };

    // Logout function
    const logout = () => {
        if (isPasswordSaved()) {
            alert('You have a saved password. Logging out...');
        } else {
            alert('No saved password detected. Logging out...');
        }
        // Perform logout action
        window.location.href = 'https://www.kogama.com/logout/'; // Adjust the logout URL as necessary
    };

    // Add event listener to the button
    logoutButton.addEventListener('click', logout);
})();