Bropezka / VirusTotal Linkify

// ==UserScript==
// @name         VirusTotal Linkify
// @namespace    https://www.virustotal.com/
// @version      1.0.0
// @description  Changes SHA-256 hash on VirusTotal result pages to VTi search links and always displays menu.
// @author       fwosar - edited by Bropezka to work with the old VT as well
// @match        https://*.virustotal.com/*/file/*
// @grant        none
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require      https://gist.github.com/raw/2625891/waitForKeyElements.js
// @updateURL    https://openuserjs.org/meta/Bropezka/VirusTotal_Linkify.meta.js
// ==/UserScript==

function linkifyHash() {
    function getElementByXpath(path) {
        return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
    }
    function searchUrl(h) {
        return 'https://www.virustotal.com/intelligence/search/?query=' + h.trim();
    }

    var xpath = '//*[@id="file-summary"]/tbody/tr[1]/td';
    var xpath2 = '//*[@id="basic-info"]//table//tbody/tr[1]/td[2]';

    var hashElement = getElementByXpath(xpath);
    var hashElement2 = getElementByXpath(xpath2);

    if (hashElement) {
        var hash = hashElement.textContent;
        hashElement.innerHTML = '<a href="' + searchUrl(hash) + '">' + hash + '</a>';
    }
    else if (hashElement2) {
        var hash2 = hashElement2.textContent;
        hashElement2.innerHTML = '<a href="' + searchUrl(hash2) + '">' + hash2 + '</a>';
    }
}

function adjustMenu() {
    if(!$('#itemActionsMenu').hasClass('opened')){
        $('#itemActionsMenu').addClass('opened');
    }
}

waitForKeyElements("#itemActionsMenu", adjustMenu);
waitForKeyElements("#file-summary", linkifyHash);
waitForKeyElements("#basic-info", linkifyHash);