[HF] Report counter

Report counter in the header.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         [HF] Report counter
// @namespace    https://hackforums.net
// @version      0.1
// @description  Report counter in the header.
// @author       iNeo19
// @match        https://hackforums.net/*
// @grant        none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// ==/UserScript==

function getElementByXpath(page, path) {
  return page.evaluate(path, page, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

var userID = "3099730";

(function() {
    'use strict';
    var profileURL = "member.php?action=profile&uid=" + userID;
    $.get(profileURL).then(function(profilePage) {
        var HTMLParser = new DOMParser();
        var page = HTMLParser.parseFromString(profilePage, "text/html");
        var reportCount = getElementByXpath(page, '//*[@id="content"]/div[2]/table[2]/tbody/tr/td[1]/table[1]/tbody/tr[8]/td[2]/text()');
        updateReports(reportCount);
    });
})();

function updateReports(reports) {
    var banner = getElementByXpath(document, '//*[@id="container"]/div[1]');
    var container = document.createElement("span");
    container.innerHTML = " (<font color='#00aaff'>Reported content: </font><font style='font-weight:normal'>"+reports.textContent+"</font>)";
    banner.appendChild(container);
}