User:Ultimate Dark Carnage/wikia.js

var ContextMenu = { actions: {}, remove: function(invoke, callback){ var $menu = $('.custom-menu'); if ($menu.length){ $menu.remove; if (invoke === true && 'function' == typeof callback){ Function.prototype.apply.call(callback, window, [ContextMenu.actions]) }       }    },    init: function(enabled){ if (!enabled) return; $('.WikiaPage').on('contextmenu', function(event){           if (event.ctrlKey){                event.preventDefault;                var $menu = $(''),                    $list = $(''),                    action_names = ['Classic Editor', 'Visual Editor', 'History', 'Rename', 'Delete', 'Purge', 'Rollback'],                    $actions = Array.prototype.map.call(action_names, function(action, index){ action = 'string' == typeof action ? action : ''; var action_key = action.toLowerCase.replace(/\s+/, '_'), $action = $(''), $link = $(''); $link.text(action); $link.on('click', function(e){                           e.preventDefault;                            ContextMenu.remove(true, function(obj){ if (!(action_key in obj)) return; Function.prototype.apply.call(obj[action_key], window, []); });                       });                        $action.html($link); return $action; });               $list.html($actions);                $menu.html($list);                $menu.css({ top: event.pageY, left: event.pageX });               if (!$('.custom-menu').length) $('.WikiaPage').append($menu);            }        }); $(document).on('click', function(event){           if ($(event.target).is('.custom-menu, .custom-menu *') === false){                ContextMenu.remove(false);            }        }); } };

ContextMenu.init(('boolean' == typeof CONTEXT_MENU_DISABLED && CONTEXT_MENU_DISABLED === true) ? false : true);