1
1
// ==UserScript==
2
2
// @name UnityForumFixer
3
3
// @namespace https://unitycoder.com/
4
- // @version 0.73 (16 .12.2024)
4
+ // @version 0.8 (21 .12.2024)
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
25
25
TopicsViewCombineViewAndReplyCounts ( ) ;
26
26
OnMouseOverPostPreview ( ) ;
27
27
28
- setTimeout ( OnUpdate , 1000 ) ; // run loop to update activity times (since some script changes them back to original..)
28
+ // update notification panel icons
29
+ const currentUserButton = document . getElementById ( 'toggle-current-user' ) ;
30
+ if ( currentUserButton ) {
31
+ currentUserButton . addEventListener ( 'click' , ( ) => {
32
+ console . log ( 1111 ) ;
33
+ // Add a slight delay to ensure the dropdown content is fully rendered
34
+ setTimeout ( replaceNotificationIcons , 1000 ) ;
35
+ } ) ;
36
+ } else {
37
+ console . warn ( 'Current user button not found.' ) ;
38
+ }
39
+
40
+
41
+ setTimeout ( OnUpdate , 1000 ) ; // run loop to update certain itesm (since something is updating them, without page refresh..)
29
42
} ) ;
30
43
44
+
31
45
} ) ( ) ;
32
46
33
47
// runs every second to update things (if you scroll the page, need to update new data)
@@ -39,6 +53,9 @@ function OnUpdate()
39
53
PostViewShowOriginalPosterInfo ( ) ;
40
54
PostViewFetchOPDetails ( ) ;
41
55
56
+ // TODO only refresh these when notification panel is opened
57
+ //replaceNotificationIcons();
58
+
42
59
setTimeout ( OnUpdate , 1000 ) ;
43
60
}
44
61
@@ -50,9 +67,12 @@ function AppendCustomCSS()
50
67
var style = document . createElement ( 'style' ) ;
51
68
style . textContent =
52
69
`
53
- // latest posts view
54
- .show-more.has-topics { width: 35%;!important;} /* updated topics alert */
55
- .alert.alert-info.clickable {width: 35%; padding:3px !important;} /* updated topics alert */
70
+ /* top banner */
71
+ .before-header-panel-outlet { text-align: center; }
72
+ .show-more.has-topics { width: 35% !important; }
73
+ /* latest posts view */
74
+ .show-more.has-topics { width: 35%;!important;}
75
+ .alert.alert-info.clickable {width: 35%; padding:3px !important;}
56
76
57
77
#main-outlet {width:auto !important;} /* smaller main forum width */
58
78
@@ -102,7 +122,7 @@ function AppendCustomCSS()
102
122
.user-name { margin-bottom: 5px; font-weight: bold; text-align: center; font-size: 0.9em; color: var(--primary); text-decoration: none; display: block; word-wrap: break-word; white-space: normal; width: 100%; }
103
123
.user-name:hover { color: rgb(82,132,189); text-decoration: underline; }
104
124
.names.trigger-user-card {visibility: hidden !important;}
105
- /* .row { display: flex; } */
125
+ /* .row { display: flex; } */
106
126
.topic-avatar { flex-basis: 10%; margin:0 !important; max-width: 45px;}
107
127
.topic-body { flex-basis: 90%; } /* Ensure the main content adjusts accordingly */
108
128
.topic-avatar {background-color: #d1d1d132;}
@@ -139,6 +159,7 @@ function AppendCustomCSS()
139
159
.custom-post-username {margin-bottom:3px;color: var(--primary);}
140
160
.custom-user-creation-date {width:45px;margin-top:6px;font: 13px 'Inter', sans-serif !important; color: rgb(150, 150, 150);}
141
161
.custom-post-preview { position: absolute; max-width: 450px; max-height: 200px; background-color: var(--primary-low); border: 1px solid black; padding: 5px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); z-index: 1000; }
162
+
142
163
143
164
` ;
144
165
document . head . appendChild ( style ) ;
@@ -464,7 +485,7 @@ function PostViewFetchOPDetails()
464
485
465
486
// Check if the current page URL has already been processed
466
487
if ( currentPageURL === prevPageURL ) {
467
- console . log ( `Skipping fetch for already processed page URL: ${ currentPageURL } ` ) ;
488
+ // console.log(`Skipping fetch for already processed page URL: ${currentPageURL}`);
468
489
return ; // Skip execution if the URL has already been processed
469
490
}
470
491
@@ -547,6 +568,92 @@ window.addEventListener('pushstate', function() {PostViewFetchOPDetails();});
547
568
window.addEventListener('replacestate', function() {PostViewFetchOPDetails();});
548
569
*/
549
570
571
+ // new post icon in followed topic
572
+ function replaceNotificationIcons ( ) {
573
+ // Define configuration for each notification type
574
+ const notificationConfig = [
575
+ {
576
+ selector : '.notification.read.posted' ,
577
+ textContent : '1' ,
578
+ backgroundColor : 'rgba(255, 0, 0, 0.6)' ,
579
+ color : 'white' ,
580
+ borderRadius : '50%' ,
581
+ fontSize : '12px'
582
+ } ,
583
+ {
584
+ selector : '.notification.read.reaction' ,
585
+ textContent : '👍' ,
586
+ backgroundColor : 'none' ,
587
+ color : 'white' ,
588
+ borderRadius : '4px' ,
589
+ fontSize : '1.25em'
590
+ } ,
591
+ {
592
+ selector : '.notification.read.mentioned' ,
593
+ textContent : '@' ,
594
+ backgroundColor : 'none' ,
595
+ color : 'var(--success)' ,
596
+ borderRadius : '4px' ,
597
+ fontSize : '1.25em'
598
+ } ,
599
+ {
600
+ selector : '.notification.read.replied' ,
601
+ textContent : '↩️' ,
602
+ backgroundColor : 'none' ,
603
+ color : 'white' ,
604
+ borderRadius : '4px' ,
605
+ fontSize : '1.25em'
606
+ } ,
607
+ {
608
+ selector : '.notification.read.granted-badge' ,
609
+ textContent : '🏆' ,
610
+ backgroundColor : 'none' ,
611
+ color : 'white' ,
612
+ borderRadius : '4px' ,
613
+ fontSize : '1.25em'
614
+ } ,
615
+ ] ;
616
+
617
+ // Process each notification type
618
+ notificationConfig . forEach ( ( { selector, textContent, backgroundColor, color, borderRadius, fontSize } ) => {
619
+ const notificationItems = document . querySelectorAll ( selector ) ;
620
+
621
+ if ( notificationItems . length > 0 ) {
622
+ notificationItems . forEach ( ( item ) => {
623
+ const icon = item . querySelector ( 'svg.fa.d-icon' ) ;
624
+ if ( icon ) {
625
+ // Create a replacement element
626
+ const newIcon = document . createElement ( 'div' ) ;
627
+ newIcon . style . cssText = `
628
+ display: inline-flex !important;
629
+ justify-content: center !important;
630
+ align-items: center !important;
631
+ background-color: ${ backgroundColor } ;
632
+ color: ${ color } ;
633
+ font-size: ${ fontSize } ;
634
+ font-weight: bold;
635
+ padding: 5px !important;
636
+ box-sizing: border-box !important;
637
+ width: 20px;
638
+ height: 20px;
639
+ min-width: 20px;
640
+ min-height: 20px;
641
+ line-height: 1;
642
+ margin-right: 8px;
643
+ border-radius: ${ borderRadius } !important;
644
+ text-align: center;
645
+ ` ;
646
+ newIcon . textContent = textContent ;
647
+
648
+ // Replace the original SVG icon
649
+ icon . replaceWith ( newIcon ) ;
650
+ }
651
+ } ) ;
652
+ }
653
+ } ) ;
654
+ }
655
+
656
+
550
657
551
658
552
659
// HELPER METHODS
0 commit comments