Auto-desbloqueio do Koo

Só para se auto-desbloquear no Koo!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name    Auto-desbloqueio do Koo
// @name:en    Self Unblock from Koo
// @namespace    https://geovani.dev/
// @version    0.2
// @description    Só para se auto-desbloquear no Koo!
// @description:en    Just for self unblocking!
// @author    Geovani Perez França
// @match    https://www.kooapp.com/*
// @icon    https://www.google.com/s2/favicons?sz=64&domain=kooapp.com
// @grant    none
// @keywords    koo,lock,self,unlock
// @license    MIT
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener('load', () => {
        addButton('Se desbloquear', selfUnblock)
    })

    function addButton(text, onclick) {
        let kooBtn = document.querySelector('a > button')

        let unblockA = document.createElement('a')
        document.body.append(unblockA)
        unblockA.innerHTML = `<button class="${kooBtn.classList.toString()}">${text}</button>`
        unblockA.onclick = onclick
        unblockA.style = "position: absolute; top: 1em; left: 1em; z-index: 999;"
        return unblockA
    }

    function getCookie(name) {
        var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
        if (match) return match[2];
    }

    function selfUnblock(element) {
        let id = getCookie("userId");
        let token = getCookie("token");

        fetch('/apiV1/users/unblock/' + id, {
            method: 'DELETE',
            headers: {token}
        })

        alert("Prontinho, seu koo tá desbloqueado!")
    }

})();