Skip to content

Commit 09aed3d

Browse files
authored
Update unity-forum-fixer.js
1 parent 49af23a commit 09aed3d

File tree

1 file changed

+71
-10
lines changed

1 file changed

+71
-10
lines changed

unity-forum-fixer.js

Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name UnityForumFixer
33
// @namespace https://unitycoder.com/
4-
// @version 0.4 (24.08.2024)
4+
// @version 0.41 (24.08.2024)
55
// @description Fixes For Unity Forums - https://github.com/unitycoder/UnityForumFixer
66
// @author unitycoder.com
77
// @match https://discussions.unity.com/*
@@ -21,7 +21,7 @@
2121
TopicsViewShowOriginalPosterInfo(); // TODO needs some css adjustments for name location
2222
FixPostActivityTime();
2323
PostViewShowOriginalPosterInfo();
24-
24+
TopicsViewCombineViewAndReplyCounts();
2525
setTimeout(OnUpdate, 1000); // run loop to update activity times (since some script changes them back to original..)
2626
});
2727
})();
@@ -49,8 +49,14 @@ function AppendCustomCSS()
4949
5050
#main-outlet {width:auto !important;} /* smaller main forum width */
5151
52-
html .heatmap-med,html .heatmap-med a,html .heatmap-med .d-icon,html .heatmap-med {color: inherit !important;} /* replies/views: heatmap colors */
53-
html .heatmap-high,html .heatmap-high a,html .heatmap-high .d-icon,html .heatmap-high {color: inherit !important; font-weight:inherit !important;} /* replies/views: heatmap colors */
52+
/* replies/views: heatmap colors */
53+
html .heatmap-med,html .heatmap-med a,html .heatmap-med .d-icon,html .heatmap-med {color: inherit !important;}
54+
html .heatmap-high,html .heatmap-high a,html .heatmap-high .d-icon,html .heatmap-high {color: inherit !important; font-weight:inherit !important;}
55+
56+
/* post titles */
57+
.title.raw-link.raw-topic-link:link {font: bold 11pt 'Inter', sans-serif;}
58+
.title.raw-link.raw-topic-link:hover {color: rgb(82,132,189) !important; text-decoration: underline !important;}
59+
body .main-link .title.raw-link.raw-topic-link:visited { font:normal !important; color: var(--primary) !important}
5460
5561
.wrap.custom-search-banner-wrap h1 {display: none;} /* hide welcome banner */
5662
.wrap.custom-search-banner-wrap {padding:0px;} /* remove search bar padding */
@@ -65,10 +71,13 @@ function AppendCustomCSS()
6571
.is-solved-label.solved {font-weight: normal !important; font-size: 12px !important; padding: 1px !important; user-select: text !important; float: right !important; } /* resolved tag, initial fixes */
6672
.badge-category__icon {display: none !important;} /* hide badge category icon for now, since most of them seem to be unity logos */
6773
.is-solved-label {display: none !important;} /* hide unresolved span, since all are unresolved, unless marked solved? */
68-
.title.raw-link.raw-topic-link {font: bold 14px/1.231 arial,helvetica,clean,sans-serif !important;} /* post title: orig forum has 13px, might use that later */
69-
.title.raw-link.raw-topic-link:hover {color: rgb(82,132,189) !important; text-decoration: underline !important;} /*post title hover */
7074
.topic-list .topic-list-data:first-of-type {padding-left: 8px !important;} /* post topic rows, half the padding */
7175
.discourse-tags {font-size: 0.8em !important;} /* tags below post title, smaller */
76+
.discourse-tag.simple {border: 1px solid rgba(var(--primary-rgb), 0.05) !important;}
77+
78+
/* if want to hide all question tags */
79+
/* a[data-tag-name="question"] { display: none !important; }*/
80+
7281
.relative-date {font-size: 0.9em !important; color: rgb(150, 150, 150) !important;}
7382
.ember-view.bread-crumbs-left-outlet.breadcrumb-label {display: none !important;} /* "… or filter the topics via" */
7483
.navigation-container {--nav-space: 0 !important; padding-bottom: 6px;} /* navbar adjustments */
@@ -104,11 +113,17 @@ function AppendCustomCSS()
104113
.unity-footer-menu.unity-footer-menu-legal.processed li { margin: 0 10px; }
105114
106115
107-
/* custom added fields */
108-
.original-poster-span {font: 13px/1.231 arial,helvetica,clean,sans-serif; color: rgb(150, 150, 150); } /* original poster below post title */
109-
.latest-poster-span { display: block; word-break: break-all; max-width: 100%; } /* activity, latest poster */
116+
/* added custom fields */
117+
.original-poster-span {font: 13px 'Inter', sans-serif !important; color: rgb(150, 150, 150); } /* original poster below post title */
118+
.latest-poster-span { display: block; word-break: break-all; max-width: 100%; font: 14px 'Inter', sans-serif !important;} /* activity, latest poster */
110119
111-
`;
120+
.combined-views-container {display: flex;justify-content: space-between;width: 100%;white-space: nowrap; font-size:13px;}
121+
.combined-views-label {color: rgb(150, 150, 150); text-align: left;}
122+
.combined-views-number {color: var(--primary); margin-left: auto;text-align: right;}
123+
124+
125+
126+
`;
112127
document.head.appendChild(style);
113128
}
114129

@@ -213,6 +228,52 @@ function TopicsViewShowOriginalPosterInfo()
213228
});
214229
}
215230

231+
function TopicsViewCombineViewAndReplyCounts()
232+
{
233+
// Select all rows in the topic list
234+
const rows = document.querySelectorAll('tr.topic-list-item');
235+
236+
// Iterate through each row
237+
rows.forEach(row => {
238+
// Get the "Replies" and "Views" cells
239+
const repliesCell = row.querySelector('td.posts');
240+
const viewsCell = row.querySelector('td.views');
241+
242+
// Check if both cells are present
243+
if (repliesCell && viewsCell) {
244+
// Create a new cell to combine the information
245+
const combinedCell = document.createElement('td');
246+
combinedCell.className = 'num topic-list-data combined-views'; // Add class for styling if needed
247+
248+
combinedCell.innerHTML = `
249+
<div class="combined-views-container">
250+
<span class="combined-views-label">Views:</span>
251+
<span class="combined-views-number">${viewsCell.innerText}</span>
252+
</div>
253+
<div class="combined-views-container">
254+
<span class="combined-views-label">Replies:</span>
255+
<span class="combined-views-number">${repliesCell.innerText}</span>
256+
</div>
257+
`;
258+
259+
// Insert the combined cell after the Replies cell
260+
repliesCell.parentNode.insertBefore(combinedCell, repliesCell);
261+
262+
// Remove the original "Replies" and "Views" cells
263+
repliesCell.remove();
264+
viewsCell.remove();
265+
}
266+
});
267+
268+
// Modify the header to have a single "Views" column
269+
const repliesHeader = document.querySelector('th.posts');
270+
const viewsHeader = document.querySelector('th.views');
271+
if (repliesHeader && viewsHeader) {
272+
repliesHeader.textContent = 'Views'; // Set the new header title
273+
viewsHeader.remove(); // Remove the "Views" header
274+
}
275+
}
276+
216277
function FixPostActivityTime()
217278
{
218279
document.querySelectorAll('.relative-date').forEach(function (el)

0 commit comments

Comments
 (0)