A code based on this suggestion https://help.forumotion.com/t50435p30-friend-request-in-posts at the same time an improvement based on this code: https://help.forumotion.com/t50435p30-#945167
In your ACP: Modules -> HTML&JAVASCRIPT -> JavaScript codes management -> [Create a new JavaScript]
Title *: <- Whatever you want
Placement : <- In topics
Javascript Code * : <- Select, copy and paste the code below in this field:
I appreciate if someone test and post a "print" of the result...
JS
In your ACP: Modules -> HTML&JAVASCRIPT -> JavaScript codes management -> [Create a new JavaScript]
Title *: <- Whatever you want
Placement : <- In topics
Javascript Code * : <- Select, copy and paste the code below in this field:
- Code:
$(function() {
if (!_userdata.session_logged_in) {
return false;
}
var FFinPosts = {
sFriend: "Add As Friend",
sFoes: "Add To Foes",
oTarget: $('.post'),
iLen: 0,
sUser_name: "",
oFF_list: null,
aFF_list: [],
vTemp: null,
oThis: null
};
FFinPosts.iLen = FFinPosts.oTarget.length;
$.ajax({
url: "/u" + _userdata.user_id + 'friends',
cache: false,
type: "get",
dataType: "text",
success: function(response, status, xhr) {
if (xhr.status == 200) {
FFinPosts.oFF_list = $('#profile-advanced-details ol .message-header > a[href^="/u"]', response);
for (var i = 0; i < FFinPosts.oFF_list.length; i++) {
FFinPosts.aFF_list[FFinPosts.aFF_list.length] = $(FFinPosts.oFF_list[i]).text();
}
for (var i = 0; i < FFinPosts.iLen; i++) {
FFinPosts.oThis = $(FFinPosts.oTarget[i]);
FFinPosts.sUser_name = FFinPosts.oThis.find('.author a, .name, .user a[href^="/u"]').text();
if (FFinPosts.sUser_name !== _userdata.username) {
FFinPosts.vTemp = FFinPosts.oThis.find('.postprofile dd:last, .postdetails.poster-profile, .user-contact');
if (FFinPosts.aFF_list.indexOf(FFinPosts.sUser_name) == -1) {
FFinPosts.vTemp.append(
'<a class="profile-icon" href="/profile?friend=' + encodeURIComponent(FFinPosts.sUser_name) + '&mode=editprofile&page_profil=friendsfoes">' +
' <img title="Add As Friend" alt="Add As Friend" src="http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/16/Actions-list-add-user-icon.png" width="25" height="25">' +
'</a>'
)
} else {
FFinPosts.vTemp.append(
'<a class="profile-icon" href="/profile?foe=' + encodeURIComponent(FFinPosts.sUser_name) + '&mode=editprofile&page_profil=friendsfoes">' +
' <img title="Add To Foes" alt="Add To Foes" src="http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/16/Actions-list-remove-user-icon.png" width="25" height="25">' +
'</a>'
)
}
}
}
}
}
});
});
I appreciate if someone test and post a "print" of the result...
JS