Advertisement
Guest User

Untitled

a guest
Jun 6th, 2021
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Better GDOS
  3. // @match       https://www.gov.pl/web/gdos/obwieszczenia-i-zawiadomienia3
  4. // @grant       none
  5. // @version     1.0
  6. // @author      bad455
  7. // ==/UserScript==
  8.  
  9. $(function() {
  10.   let $articles = $('.article-area__article li > a'),
  11.       articles = JSON.parse(localStorage.getItem('articles') || '{}');
  12.  
  13.   $articles.each(function() {
  14.     let $article = $(this),
  15.         href = $article.attr('href');
  16.    
  17.     if(articles.hasOwnProperty(href)) {
  18.       displayDesc($article, articles[href]);
  19.      
  20.       return;
  21.     }
  22.        
  23.     $.get(href, function(response) {
  24.       let desc = $(response).find('.article-area__article .editor-content p').text();
  25.       displayDesc($article, desc);
  26.      
  27.       articles[href] = desc;
  28.       localStorage.setItem('articles', JSON.stringify(articles));
  29.     });
  30.   });
  31. });
  32.  
  33. function displayDesc($article, desc) {
  34.   let $desc = $('<div>'+desc+'</div>').insertAfter($article);
  35.  
  36.   $article.css('margin-bottom', '0.5em');
  37.   $desc.css('margin-bottom', '2em');
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement