dryxie

Hide Useless Blogs

Apr 20th, 2025
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Hide Low Rated Author Blogs and Contest Announcements Blogs in Recent Actions (Codeforces)
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Hide blog entries in the sidebar from authors with specific titles (e.g., "Newbie", "Pupil")
  6. // @author You
  7. // @match https://codeforces.com/*
  8. // @connect codeforces.com
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. const threshhold_title = ['Newbie', 'Pupil'];
  15.  
  16. function hideblogs() {
  17. const list = document.querySelectorAll('.recent-actions ul li');
  18.  
  19. list.forEach((action) => {
  20. const userlink = action.querySelector('a.rated-user');
  21. const curr_title = userlink.getAttribute('title');
  22. const tohide = threshhold_title.some(title => curr_title && curr_title.includes(title));
  23. if (tohide) {
  24. action.style.display = "none";
  25. }
  26. else {
  27. const blogTitleElement = action.querySelector('a[href^="/blog/entry"]');
  28. const blogTitle = blogTitleElement ? blogTitleElement.textContent : '';
  29.  
  30. if (blogTitle.includes("Codeforces Round") | blogTitle.includes("cheater") | blogTitle.includes("ban") | blogTitle.includes("cheaters")) {
  31. action.style.display = "none";
  32. }
  33. }
  34. });
  35. }
  36.  
  37. const observer = new MutationObserver(() => {
  38. hideblogs();
  39. });
  40.  
  41. observer.observe(document.querySelector('.recent-actions'), {
  42. childList: true,
  43. subtree: true
  44. });
  45.  
  46. hideblogs();
  47. })();
  48.  
Add Comment
Please, Sign In to add comment