User:Fumple/common.js

var s1 = document.createElement("script"); var s2 = document.createElement("script"); var s3 = document.createElement("link"); s1.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.7.1/jquery.contextMenu.min.js"; s2.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.7.1/jquery.ui.position.js"; s3.rel = "stylesheet"; s3.href = "https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.7.1/jquery.contextMenu.min.css"; document.body.append(s1); document.body.append(s2); document.body.append(s3); var contexts = {}; contexts[""] = $(".-context-menu"); contexts["user"] = $(".-context-menu-user"); function prepareContext { if ($.contextMenu == null) { setTimeout(prepareContext, 10); }           else { $(function {                    $.contextMenu({ selector: "a[name^='User:'], a[name^='User talk:']", callback: function (key, options) { var m = "clicked: " + key; window.console && console.log(m) || alert(m); },                       items: { "user": { name:"User:", disabled: true }, "block": { name: "Block user", icon: "quit" }, "contribs": { name: "User contribs" }, "groups": { name: "User groups" }, "page": { name: "User page" }, "talk": { name: "User talk" }, "sep1": "-", "newtab": {name:"Open "} }                   });                });            }        }        prepareContext;