@@ -53,22 +53,33 @@ func (h *SteamDownloaderAPI) SteamProxyHandler(c *gin.Context) {
53
53
}
54
54
55
55
proxy .ModifyResponse = func (res * http.Response ) error {
56
- if ! strings .Contains (res .Header .Get ("Content-Type" ), "text/html" ) {
57
- return nil
58
- }
59
-
60
56
body , err := io .ReadAll (res .Body )
61
57
if err != nil {
62
58
return fmt .Errorf ("failed to read response body: %w" , err )
63
59
}
64
60
65
61
defer res .Body .Close ()
66
62
63
+ if ! strings .Contains (res .Header .Get ("Content-Type" ), "text/html" ) {
64
+ body = bytes .ReplaceAll (body ,
65
+ []byte ("https://steamcommunity.com/workshop/ajaxfindworkshops" ),
66
+ []byte ("/workshop/ajaxfindworkshops" ),
67
+ )
68
+
69
+ res .Body = io .NopCloser (bytes .NewReader (body ))
70
+ return nil
71
+ }
72
+
67
73
doc , err := goquery .NewDocumentFromReader (bytes .NewReader (body ))
68
74
if err != nil {
69
75
return fmt .Errorf ("failed to parse HTML: %w" , err )
70
76
}
71
77
78
+ titleElm := doc .Find ("title" )
79
+ title := titleElm .Text ()
80
+ title = strings .Replace (title , "Steam Community" , "SteamDownloaderAPI" , 1 )
81
+ titleElm .SetText (title )
82
+
72
83
replacedCollection := true
73
84
74
85
doc .Find ("a[onclick*='SubscribeItem']" ).Each (func (i int , s * goquery.Selection ) {
@@ -80,6 +91,10 @@ func (h *SteamDownloaderAPI) SteamProxyHandler(c *gin.Context) {
80
91
}
81
92
})
82
93
94
+ doc .Find (`span[class="valve_links"]` ).Each (func (i int , s * goquery.Selection ) {
95
+ s .AppendHtml (` | <a style="color: #1497cb;font-weight: bold;font-size: medium;" href="https://github.com/SyNdicateFoundation/SteamDownloaderAPI" target="_blank">SteamDownloaderAPI GitHub</a>` )
96
+ })
97
+
83
98
doc .Find (".subscribe[onclick*='SubscribeCollection']" ).Each (func (i int , s * goquery.Selection ) {
84
99
onclick , _ := s .Attr ("onclick" )
85
100
if matches := infoRegex .FindStringSubmatch (onclick ); len (matches ) == 3 {
0 commit comments