Wykop Profile Link

Robi zwykły link z przycisku profilu w headerze wykopu. Menu pojawia się poprzez samo najechanie na przycisk profilu.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Wykop Profile Link
// @description	Robi zwykły link z przycisku profilu w headerze wykopu. Menu pojawia się poprzez samo najechanie na przycisk profilu.
// @version     1.0
// @author      look997
// @include     https://wykop.pl/*
// @homepageURL https://wykop.pl/ludzie/addons/look997/
// @namespace   https://wykop.pl/ludzie/addons/look997/
// @grant       none
// @run-at      document-end
// @icon        https://www.google.com/s2/favicons?domain=wykop.pl
// @icon64      https://www.google.com/s2/favicons?domain=wykop.pl
// ==/UserScript==

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}


let oldHref = document.location.href;

const bodyList = document.querySelector("body");
const observer = new MutationObserver(function(mutations) {
  mutations.forEach(function(mutation) {
    if (oldHref !== document.location.href) {
      oldHref = document.location.href;
      // console.log("Wykop Script Tester - test 1");
      run();
    }
  });
});
const config = {
  childList: true,
  subtree: true
};
observer.observe(bodyList, config);
run();

async function run () {
  // console.log("Wykop Script Tester - test 1");

  await sleep(100);

  const profileEl = document.querySelector(".account");

  if (!profileEl) { return; }
  const pEl = profileEl;
  pEl.addEventListener("mouseenter", async ()=>{
    // console.log("me a",profileEl.classList.contains("active"));
    if (profileEl.classList.contains("active")===false) {
    // console.log("me b");
      const menuEl = profileEl.querySelector(":scope > .dropdown-body");
      // console.log("menuEl",menuEl);
      menuEl.setAttribute("style", "top: 34px;");
      // menuEl.style.top = "34px";
      profileEl.click();
      // await sleep(100);
      addA();
    // console.log("me c");
    //   profileEl.addEventListener("click", open);
    // // console.log("me d");
    //   profileEl.addEventListener("mouseup", openNew);
    }
  });
  pEl.addEventListener("mouseleave", ()=>{
    if (profileEl.classList.contains("active")===true) {
      // profileEl.removeEventListener("click", open);
      // profileEl.removeEventListener("mouseup", openNew);
      removeA();
      profileEl.click();
      const menuEl = profileEl.querySelector(":scope > .dropdown-body");
      menuEl.removeAttribute("style");
    }
  });
  function addA () {
    profileEl.querySelector(":scope > a").href = profileEl.querySelector(":scope > a > a").href;
  }
  function removeA () {
    profileEl.querySelector(":scope > a").removeAttribute("href");
  }



}