Advertisement
Guest User

Hejto Profile Link

a guest
Feb 24th, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Hejto Profile Link (Hejto Script Tester)
  3. // @namespace Violentmonkey Scripts
  4. // @match https://www.hejto.pl/*
  5. // @grant none
  6. // @version 1.0
  7. // @author fewtoast
  8. // @description 25.02.2023, 02:45:25
  9. // ==/UserScript==
  10.  
  11. function sleep(ms) {
  12. return new Promise(resolve => setTimeout(resolve, ms));
  13. }
  14.  
  15.  
  16. let oldHref = document.location.href;
  17.  
  18. const bodyList = document.querySelector("body");
  19. const observer = new MutationObserver(function(mutations) {
  20. mutations.forEach(function(mutation) {
  21. if (oldHref !== document.location.href) {
  22. oldHref = document.location.href;
  23. // console.log("Hejto Script Tester - test 1");
  24. run();
  25. }
  26. });
  27. });
  28. const config = {
  29. childList: true,
  30. subtree: true
  31. };
  32. observer.observe(bodyList, config);
  33. run();
  34.  
  35. async function run () {
  36. // console.log("Hejto Script Tester - test 1");
  37.  
  38. await sleep(4000);
  39.  
  40. const profileEl = document.querySelector("button.block");
  41.  
  42. if (!profileEl) { return; }
  43.  
  44. // function open (e) {
  45. // const url = `https://www.hejto.pl/uzytkownik/${profileEl.firstChild.getAttribute("alt")}`;
  46. // window.document.location = url;
  47. // e.preventDefault();
  48. // return false;
  49. // }
  50. // function openNew (e) {
  51. // if (e.button===1) {
  52. // const url = `https://www.hejto.pl/uzytkownik/${profileEl.firstChild.getAttribute("alt")}`;
  53. // window.open(url);
  54. // e.preventDefault();
  55. // return false;
  56. // }
  57. // }
  58. // console.log("profileEl",profileEl);
  59. const pEl = profileEl.parentElement;
  60. pEl.addEventListener("mouseenter", async ()=>{
  61. // console.log("me a");
  62. if (profileEl.getAttribute("aria-expanded")==="false") {
  63. // console.log("me b");
  64. profileEl.click();
  65. await sleep(100);
  66. addA();
  67. // console.log("me c");
  68. // profileEl.addEventListener("click", open);
  69. // // console.log("me d");
  70. // profileEl.addEventListener("mouseup", openNew);
  71. }
  72. });
  73. pEl.addEventListener("mouseleave", ()=>{
  74. if (profileEl.getAttribute("aria-expanded")==="true") {
  75. // profileEl.removeEventListener("click", open);
  76. // profileEl.removeEventListener("mouseup", openNew);
  77. removeA();
  78. profileEl.click();
  79. }
  80. });
  81. function addA () {
  82. const aEl = document.createElement("a");
  83. aEl.href = `https://www.hejto.pl/uzytkownik/${profileEl.firstChild.getAttribute("alt")}`;
  84. aEl.append(profileEl);
  85. pEl.append(aEl);
  86. }
  87. function removeA () {
  88. pEl.append(profileEl);
  89. pEl.querySelector("a").remove();
  90. }
  91.  
  92.  
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement