Jump to content

User:Golfpecks256/chat.js

From SpongeBob Wiki
Revision as of 14:04, 17 July 2019 by imported>Golfpecks256
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
window.logInterval = 60000;
importArticles({
    type: 'script',
    articles: [
     'u:dev:ChatLogger.js',
     'u:dev:FucodeLogger.js',
     'u:dev:FasterBanModule/code.js',
     'u:dev:MediaWiki:!kick/code.js',
     'u:dev:MediaWiki:!ban/code.js',
     'u:dev:ChatAwayButton/code.js',
     'u:dev:ChatSendButton.js',
     'u:dev:ChatOptions/code.js',
     'u:dev:CustomChatPings/code.js',
     'u:dev:FasterBanModule/code.js',
     'u:dev:MessageBlocker/code.js',
     'u:electroboom:User:Mario&LuigiBowser\'sInsideStory/AjaxBanButtons.javascript',
     'u:thekorrafanatic:FasterBanModule/code.js',
    ]
});

window.ajaxBanButtons = [
    {
        reason: 'Abusing Multiple Accounts.',
        expiry: 'infinite',
        label: 'Sock',
    },
    {
        reason: 'Troll.',
        expiry: 'infinite',
        label: 'Troll'
    },
    {
        reason: 'Behavior issues.',
        expiry: '1 day',
        label: 'Misbehaving.'
    },
    {
        reason: 'Ignoring warnings.',
        expiry: '3 days',
        label: 'Ignoring warnings'
    },
    {
        reason: 'Trolling.',
        expiry: '1 week',
        label: 'Trolling'
    },
{
        reason: 'Excessive spam.',
        expiry: 'infinite',
        label: 'Excessive Spam '
    },
    {
        reason: 'Spam.',
        expiry: '1 week',
        label: 'Spam'
    }
];
 
var blinkInterval = 1000; // Custom blink delay, 1000ms is default
importScriptPage('MediaWiki:PrivateMessageAlert/code.js', 'dev');
 
importScriptPage('User:Monchoman45/ChatHacks.js', 'community');
 
importScriptPage('User:Madnessfan34537/multikick.js', 'callofduty');
 
importArticles( {
    type: 'script',
    articles: [
        "u:dev:ChatOptions/code.js",
    ]
} );
 
/* ChatPlugins */
 
var ChatPlugins = {
release: {
version: 1.1,
branch: "Stable"
},
models: {
feature: function(id, name, access, script) {
this.enabled = false;
this.id = id;
this.name = name;
this.access = access;
this.script = script;
},
alert: function(text) {
newInlineAlert = new models.InlineAlert();
newInlineAlert.attributes.text = text;
mainRoom.model.chats.add(newInlineAlert);
},
command: function(command, script) {
this.command = command;
this.script = script;
}
},
features: {},
settings: {
release: {
version: 1.0,
branch: "Stable"
},
icons: {
staffIcon: "http://img1.wikia.nocookie.net/__cb20140626173406/gamedezyner/images/6/60/StaffIcon.png",
modIcon: "http://img1.wikia.nocookie.net/__cb20140626173343/gamedezyner/images/8/89/ModIcon.png"
},
sounds: {
pingSound: "https://notificationsounds.com/soundfiles/9461cce28ebe3e76fb4b931c35a169b0/file-sounds-1044-inquisitiveness.mp3"
},
features: {
pings: true
}
},
save: function() {
ChatPlugins.settings.features.pings = ChatPlugins.features.pings.enabled;
api.functions.editPage("User:" + wgUserName + "/ChatPlugins.js", JSON.stringify(ChatPlugins.settings));
},
load: function() {
new ChatPlugins.models.alert("Welcome to Chat Plugins 1.0!");
pagecontents = api.functions.getPageContents("User:" + wgUserName + "/ChatPlugins.js");
if (pagecontents == "error") {
new ChatPlugins.models.alert("There seems to be something wrong with your settings file, or it doesn't exist yet. Default settings have been saved.");
ChatPlugins.save();
} else {
ChatPlugins.settings = JSON.parse(pagecontents);
ChatPlugins.features.pings.enabled = ChatPlugins.settings.features.pings;
ChatPlugins.features.pings.words = ChatPlugins.settings.pings;
}
pagecontents = api.functions.getPageContents("MediaWiki:ChatPluginsSettings.js");
if (pagecontents != "error") {
wikicustom = JSON.parse(pagecontents);
if (typeof(wikicustom.settings) != "object") {
new ChatPlugins.models.alert("This wiki has a custom settings page, but it is broken.");
} else {
ChatPlugins.settings.icons = wikicustom.settings.icons; //Load Wiki-specific icons
ChatPlugins.settings.sounds = wikicustom.settings.sounds; //Load Wiki-specific sounds
new ChatPlugins.models.alert("This wiki has custom settings and they have been applied.");
}
 
}
}
};
// Call API
function callAPI(data, method, callback) {
data.format = 'json';
$.ajax({
data: data,
dataType: 'json',
url: wgScriptPath + '/api.php',
type: method,
success: function(response) {
if (response.error)
showError('API error: ' + response.error.info);
else
callback(response);
},
error: function(xhr, error) {
showError('AJAX error: ' + error);
}
});
}
//Inline-mod tools
function scrollToBottom() {
var chat = document.getElementById('Chat_' + mainRoom.roomId);
chat.scrollTop = chat.scrollHeight;
}
ChatPlugins.features.modIcons = new ChatPlugins.models.feature(null, "Mod Icons", 0, function(chat) {
var time = new Date();
var hours = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();
if ( hours < 10) hours = '0' + hours;
if (minutes < 10) minutes = "0" + minutes;
if (seconds < 10) seconds = "0" + seconds;
mainRoom.viewDiscussion.chatUL.children().last().children(".message").attr('msg-source', chat.attributes.text);
mainRoom.viewDiscussion.chatUL.children().last().children(".message").attr('msg-time', hours + ':' + minutes + ':' + seconds);
var icon = '';''
mainRoom.viewDiscussion.chatUL.children().last().children('.message').hover(
function() {
thistarget = this;
username = $(thistarget).parent().attr("data-user");
timestamp = $(thistarget).attr('msg-time');
message = $(thistarget).attr('msg-source');
$(thistarget).append('<span class="inline-quote" style="color: #3cd7fa !important;cursor:pointer;">&nbsp;&nbsp;Quote</span>');
$(thistarget).children('.inline-quote').click(function(e) {
if ( e.shiftKey ) {
$('.message textarea').val($('.message textarea').val() + '[' + timestamp + '] ' + username + ": " + message.replace(/^\/me/, "* " + username) + '\n');
} else {
$('.message textarea').val('[' + timestamp + '] ' + username + ": " + message.replace(/^\/me/, "* " + username) + '\n');
scrollToBottom();
}
$(".message textarea").focus();
});
 
},
function() {
$(this).children('.inline-quote').remove();
}
);
}
);
//Bind function to chat updates
setTimeout(function() {
mainRoom.model.chats.bind('afteradd', ChatPlugins.features.modIcons.script, mainRoom.viewDiscussion);
}, 15000);