1
1
// ==UserScript==
2
2
// @name UnityForumFixer
3
3
// @namespace https://unitycoder.com/
4
- // @version 0.87 (26.05 .2025)
4
+ // @version 0.88 (27.07 .2025)
5
5
// @description Fixes For Unity Forums - https://github.com/unitycoder/UnityForumFixer
6
6
// @author unitycoder.com
7
7
// @match https://discussions.unity.com/latest
@@ -465,36 +465,36 @@ function stripHtmlTags(html) {
465
465
466
466
// POST VIEW
467
467
468
- function PostViewShowOriginalPosterInfo ( )
469
- {
470
- // Select all elements that contain the avatar with a data-user-card attribute
471
- document . querySelectorAll ( '.trigger-user-card.main-avatar' ) . forEach ( function ( avatar ) {
472
- // Check if the user link has already been added
473
- if ( avatar . parentNode . querySelector ( '.custom-post-username' ) ) {
474
- return ; // Skip to the next avatar if the user link already exists
475
- }
468
+ function PostViewShowOriginalPosterInfo ( ) {
469
+ // Loop through all avatar anchors that represent a user
470
+ document . querySelectorAll ( '.post-avatar' ) . forEach ( postAvatar => {
471
+ const avatarLink = postAvatar . querySelector ( 'a.main-avatar[data-user-card]' ) ;
472
+ if ( ! avatarLink ) return ;
476
473
477
- // Get the user name from the data-user-card attribute
478
- var userName = avatar . getAttribute ( 'data-user-card' ) ;
474
+ // Check if we've already added the username
475
+ if ( postAvatar . querySelector ( '.custom-post-username' ) ) return ;
479
476
480
- // Create a new anchor element to wrap the user name and link to the profile
481
- var userLink = document . createElement ( 'a' ) ;
477
+ const username = avatarLink . getAttribute ( 'data-user-card' ) ;
478
+ if ( ! username ) return ;
479
+
480
+ const userLink = document . createElement ( 'a' ) ;
482
481
userLink . className = 'custom-post-username' ;
483
- userLink . href = 'https://discussions.unity.com/u/' + userName ;
484
- userLink . textContent = userName ;
482
+ userLink . href = `/u/ ${ username } ` ;
483
+ userLink . textContent = username ;
485
484
486
- // Insert the user name link before the avatar image
487
- avatar . parentNode . insertBefore ( userLink , avatar ) ;
485
+ // Insert username under the avatar
486
+ postAvatar . appendChild ( userLink ) ;
488
487
} ) ;
489
-
490
488
}
491
489
490
+
492
491
let prevPageURL = '' ;
493
492
function PostViewFetchOPDetails ( )
494
493
{
495
494
// Get the current page URL
496
495
const currentPageURL = window . location . href ;
497
496
497
+
498
498
// Check if the current page URL has already been processed
499
499
if ( currentPageURL === prevPageURL ) {
500
500
//console.log(`Skipping fetch for already processed page URL: ${currentPageURL}`);
@@ -507,14 +507,16 @@ function PostViewFetchOPDetails()
507
507
// Select all elements with the specified classes to get usernames
508
508
const usernames = new Set ( ) ; // Using a Set to avoid duplicates
509
509
510
- // Find usernames from elements with class 'trigger-user-card main- avatar'
511
- document . querySelectorAll ( '.trigger- user-card.main-avatar ' ) . forEach ( function ( avatar ) {
510
+ // Find usernames from main avatar links
511
+ document . querySelectorAll ( 'a.main-avatar[data- user-card] ' ) . forEach ( function ( avatar ) {
512
512
const userName = avatar . getAttribute ( 'data-user-card' ) ;
513
513
if ( userName ) {
514
- usernames . add ( userName ) ; // Add to the Set
514
+ usernames . add ( userName ) ;
515
515
}
516
516
} ) ;
517
517
518
+
519
+
518
520
// Convert the Set to an Array and limit to the first 3 users
519
521
const userArray = Array . from ( usernames ) . slice ( 0 , 3 ) ;
520
522
@@ -557,7 +559,7 @@ function PostViewFetchOPDetails()
557
559
creationDateElement . textContent = `Joined: ${ formattedDate } ` ;
558
560
559
561
// Find all post-avatar divs associated with this user
560
- document . querySelectorAll ( '.trigger- user-card.main-avatar ' ) . forEach ( function ( avatarElement ) {
562
+ document . querySelectorAll ( 'a.main-avatar[data- user-card] ' ) . forEach ( function ( avatarElement ) {
561
563
if ( avatarElement . getAttribute ( 'data-user-card' ) === userName ) {
562
564
const postAvatarDiv = avatarElement . closest ( '.post-avatar' ) ;
563
565
if ( postAvatarDiv && ! postAvatarDiv . querySelector ( '.custom-user-creation-date' ) ) {
0 commit comments