假装自己是三级

三级用户的图标我也要

// ==UserScript==
// @name         假装自己是三级
// @namespace    https://linux.do
// @version      0.0.1
// @description  三级用户的图标我也要
// @author       DengDai
// @match        https://linux.do/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=linux.do
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    let username = document.getElementsByClassName("header-dropdown-toggle current-user")[0].querySelector("button").getAttribute("href").replace("/u/","").toLowerCase();
    let divs = document.getElementsByClassName("post-avatar");
    var level3_div = document.createElement("div");
    level3_div.className = "avatar-flair avatar-flair-trust_level_3 rounded avatar-flair-image";
    level3_div.style.backgroundImage = "url(https://cdn.linux.do/uploads/default/original/3X/9/d/9d8a9be47928b3e1a35aaf632f9eeafa32600765.png)";
    level3_div.style.backgroundColor = "#2e303d";
    level3_div.style.color = "#fff";
    level3_div.setAttribute("title", "trust_level_3");
    for (var i = 0; i < divs.length; i++) {
        var link = divs[i].getElementsByTagName("a")[0];
        var hrefValue = link.getAttribute("href").toLowerCase();
        // 检查href属性是否包含特定值
        if (hrefValue.includes(username)) {
            divs[i].appendChild(level3_div);
            console.log(hrefValue);
        }
    }

})();