Wykop Profile Link

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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");
  }



}