Advertisement
Guest User

Untitled

a guest
Jan 20th, 2023
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Hejto
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       You
  7. // @match        https://www.hejto.pl/*
  8. // @icon         https://www.google.com/s2/favicons?sz=64&domain=hejto.pl
  9. // @run-at       document-start
  10. // @grant        GM_addStyle
  11. // ==/UserScript==
  12.  
  13. // Nie wyświetlaj formularzy odpowiedzi zanim nie zostanie kliknięty przycisk Odpowiedz
  14. GM_addStyle('div.p-3 > form {display: none}')
  15. // Zmiana wyglądu postów i odpowiedzi
  16. GM_addStyle('article {background-color: rgb(41 41 41) !important; padding-left: 10px !important; margin-left: 10px !important;}')
  17. GM_addStyle('article > * {background-color: rgb(41 41 41) !important; padding-left: 10px !important; margin-left: 10px !important;}')
  18. GM_addStyle('.basic-text {color: white !important; font-size: 12px !important;}')
  19. // Zmniejszenie boxów z postem
  20. GM_addStyle('article > div > div .items-start {align-items: flex-start !important; border-bottom: 1px solid #504f4f !important; padding-bottom: 10px !important;}')
  21. GM_addStyle('article > div {padding: 6px !important;}')
  22. // Ukryj przyciski Odpowiedz
  23. GM_addStyle('article > div > div > div > div  button.self-end {padding-top: 5px !important; padding-bottom: 0px !important; font-size: 12px !important; opacity: 20% !important;}')
  24.  
  25. // Dodaj przycisk na górnej belce
  26. function add_button(link, napis, css) {
  27.     var button = document.createElement("a");
  28.     button.href = link;
  29.     button.text = napis;
  30.     button.style = css;
  31.  
  32.     var bar = document.getElementsByClassName("flex-grow")[0];
  33.     bar.appendChild(button);
  34. }
  35.  
  36. // Wyświetlaj formularz odpowiedzi po wciśnięciu przycisku Odpowiedz
  37. function button_odp_click(element) {
  38.     element.target.closest('article').getElementsByTagName("form")[0].style = "display: block";
  39. }
  40.  
  41. // Pokazywanie i ukrywanie przycisków Odpowiedz po najechaniu myszką
  42. function post_mouseover(element) {
  43.     var buttons = element.target.closest('div').getElementsByTagName("button");
  44.     for(let i=0; i < buttons.length; i++) {
  45.         if(buttons[i].textContent == "Odpowiedz") {
  46.             buttons[i].style = "opacity: 100% !important;";
  47.         }
  48.     }
  49. }
  50.  
  51. function post_mouseout(element) {
  52.     var buttons = element.target.closest('div').getElementsByTagName("button");
  53.     for(let i=0; i < buttons.length; i++) {
  54.         if(buttons[i].textContent == "Odpowiedz") {
  55.             buttons[i].style = "opacity: 20% !important;";
  56.         }
  57.     }
  58. }
  59.  
  60. // Dodaj wszystkie dodatkowe przyciski na górnej belce
  61. function after_loading() {
  62.     var buton_style =
  63.         "font-weight: bold;" +
  64.         "background-color: rgb(41 41 41);" +
  65.         "color: white;" +
  66.         "margin-left: 10px;" +
  67.         "margin-right: 10px;" +
  68.         "padding: 10px 10px 10px 10px;";
  69.     add_button("", "", "visibility: hidden; margin-left: 20px;");
  70.     add_button("https://www.hejto.pl/", "Gorące", buton_style);
  71.     add_button("https://www.hejto.pl/najnowsze", "Najnowsze", buton_style);
  72.     add_button("https://www.hejto.pl/najnowsze/typ/artykuly", "Artykuły", buton_style);
  73.  
  74.     // Mouseover dla boxów z odpowiedziami
  75.     var box = document.querySelectorAll('.relative > div:not([class])');
  76.     for(let i=0; i < box.length; i++) {
  77.         box[i].addEventListener("mouseover", post_mouseover);
  78.         box[i].addEventListener("mouseout", post_mouseout);
  79.     }
  80. }
  81.  
  82. // Wygląd postów i odpowiedzi, odświeżany co 1 sekundę
  83.  
  84. window.setInterval(function(){
  85.     // Przyciski odpowiedzi
  86.     var odp = document.querySelectorAll("article > div > div > div button")
  87.     for(let i=0; i < odp.length; i++) {
  88.         if(odp[i].textContent == "Odpowiedz") {
  89.             //odp[i].style = "padding-top: 5px; padding-bottom: 0px; font-size: 12px; visibility: hidden;";
  90.             odp[i].addEventListener("click", button_odp_click);
  91.         }
  92.     }
  93. }, 500);
  94.  
  95. (function() {
  96.     'use strict';
  97.     // Dodaj przyciski na górnej belce po załadowaniu strony
  98.     window.addEventListener('load', after_loading)
  99. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement