moped / pc.sk RSS

// ==UserScript==
// @name         pc.sk RSS
// @namespace    pretaktovanie.sk
// @version      1.0
// @description  RSS parser pre forum
// @author       moped
// @license      MIT
// @match        https://pretaktovanie.zoznam.sk/*
// @exclude      https://pretaktovanie.zoznam.sk/ucp.php*
// @icon         https://pretaktovanie.zoznam.sk/favicon.ico
// @grant        GM_xmlhttpRequest
// @grant        GM_setValue
// @grant        GM_getValue
// @connect      pc.zoznam.sk
// @run-at       document-end
// ==/UserScript==

(function () {
  'use strict';

  var lastCheck = GM_getValue('lastCheck');
  var rssList = GM_getValue('rssList');
  var currTime = Date.now();

  if ((lastCheck === undefined && rssList === undefined) || (lastCheck + 300000) < currTime) {
    GM_xmlhttpRequest({
      method: "GET",
      url: "https://pc.zoznam.sk/rss",
      onload: function (response) {
        if (response.status === 200) {
          var item = response.responseXML.getElementsByTagName('item');
          var list = "<div id=\"pc-rss\" style=\"width: 650px; text-align: left; float: right; font-size: 1.1em; line-height: 2\"><h4>Novinky <a target=\"_blank\" href=\"http://pc.zoznam.sk\">pc.sk</a></h4><ul style=\"list-style: none;\">";
          for (var i = 0; i < item.length; i++) {
            var d = new Date(item[i].children[3].textContent);
            var utcString = d.toUTCString();
            var iDate = utcString.substring(5, 11);
            var iTime = utcString.substring(17, 22);
            var title = item[i].children[0].textContent;
            var link = item[i].children[1].textContent;
            list += "<li><a target=\"_blank\" href=\"" + link + "\" title=\"" + title + "\"><b>" + iDate + "</b> <i>" + iTime + "</i> " + title + "</a></li>";
          }
          list += "</ul></div>";
          GM_setValue('rssList', list);
          GM_setValue('lastCheck', currTime);
        }
      }
    });
  }

  var divBlock = document.querySelector("#page-body > div.align-center");
  if (rssList !== undefined && divBlock !== null) divBlock.insertAdjacentHTML('afterbegin', rssList);
})();