Skip to content

Instantly share code, notes, and snippets.

@amayiruKiariM
Last active December 23, 2016 23:46
Show Gist options
  • Save amayiruKiariM/49e37d89c66946721aca3d7d987f422c to your computer and use it in GitHub Desktop.
Save amayiruKiariM/49e37d89c66946721aca3d7d987f422c to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Apollo Custom users
// @namespace by Mirai
// @description Substitute reality with your own.
// @include https://apollo.rip/forums.php?action=viewthread*
// @include https://apollo.rip/forums.php?page*
// @include https://apollo.rip/comments.php?*
// @include https://apollo.rip/torrents.php?*
// @include https://apollo.rip/staffpm.php?*
// @include https://apollo.rip/user.php?*
// @version 1
// @grant none
// ==/UserScript==
document.addEventListener('DOMContentLoaded', function () {
var obj,
Users = [
{
'id': '',
'avatar': '',
'title': ''
},
{
'id': '18167',
'avatar': 'https://vgy.me/eDjMJK.png',
'title': 'Example'
}
];
function getUserPosts(userID) {
var userPost = $('.colhead_dark a[href$=' + userID + ']');
return userPost;
};
function setAvatar(userID, customAvatar) {
var parent = getUserPosts(userID);
var userAvatar = parent.closest('tbody').find('.avatar div img');
userAvatar.attr('src', customAvatar);
};
function setTitle(userID, customTitle) {
var parent = getUserPosts(userID);
var userTitle = parent.closest('tbody').find('.user_title');
var container = '<span class="user_title"></span>';
var titleLocation = parent.closest('tbody').find('.time');
if (userTitle.length === 0) {
titleLocation.before(container);
var userTitle = parent.closest('tbody').find('.user_title');
userTitle.text(customTitle);
} else {
userTitle.text(customTitle);
return userTitle
}
};
function customizeUsers(obj) {
var id = obj.id,
avatar = obj.avatar,
title = obj.title;
if (avatar.length > 0) {
setAvatar(id, avatar);
}
if (title.length > 0) {
setTitle(id, title);
}
};
for (var obj = 0; obj < Users.length; obj++) {
customizeUsers(Users[obj]);
};
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment