Javascript

Library

Snippets

Inject xpath function into Browser

var XPATH_NAMESPACE = {svg: 'http://www.w3.org/2000/svg',mathml: 'http://www.w3.org/1998/Math/MathML'};
function xpathNamespaceResolver(prefix) {
    return XPATH_NAMESPACE[prefix] || null;
}
function getElementByXPath(expression) {
    var a = document.evaluate(expression, document, xpathNamespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    if (a.snapshotLength > 0) {
        return a.snapshotItem(0);
    }
};

Inject jQuery Library into Browser

(function() {
    var script = document.createElement("script");
    script.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js");
    script.addEventListener('load', function() {
        var script = document.createElement("script");
        document.body.appendChild(script);
    }, false);
    document.body.appendChild(script);
})();
Last modified 3 years ago Last modified on 06/16/17 19:02:59