mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
Raw settings
This commit is contained in:
+32
-1
@@ -6,6 +6,8 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
httpc "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
@@ -114,6 +116,28 @@ func setCookie(c *fiber.Ctx) error {
|
||||
return fmt.Errorf("Invalid Cookie Name: %s", key)
|
||||
}
|
||||
|
||||
func setRawCookie(c *fiber.Ctx) error {
|
||||
raw := c.FormValue("raw")
|
||||
lines := strings.Split(raw, "\n")
|
||||
|
||||
for _, line := range lines {
|
||||
sub := strings.Split(line, "=")
|
||||
if len(sub) != 2 {
|
||||
continue
|
||||
}
|
||||
|
||||
name := session.CookieName(sub[0])
|
||||
value := sub[1]
|
||||
|
||||
if !slices.Contains(session.AllCookieNames, name) {
|
||||
continue
|
||||
}
|
||||
|
||||
session.SetCookie(c, name, value)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func resetAll(c *fiber.Ctx) error {
|
||||
session.ClearAllCookies(c)
|
||||
return nil
|
||||
@@ -136,6 +160,7 @@ func SettingsPage(c *fiber.Ctx) error {
|
||||
|
||||
func SettingsPost(c *fiber.Ctx) error {
|
||||
t := c.Params("type")
|
||||
var noredirect bool = false
|
||||
var err error
|
||||
|
||||
switch t {
|
||||
@@ -149,10 +174,14 @@ func SettingsPost(c *fiber.Ctx) error {
|
||||
err = resetAll(c)
|
||||
case "novelFontType":
|
||||
err = setNovelFontType(c)
|
||||
noredirect = true
|
||||
case "novelViewMode":
|
||||
err = setNovelViewMode(c)
|
||||
noredirect = true
|
||||
case "set-cookie":
|
||||
err = setCookie(c)
|
||||
case "raw":
|
||||
err = setRawCookie(c)
|
||||
default:
|
||||
err = errors.New("No such setting is available.")
|
||||
}
|
||||
@@ -161,7 +190,9 @@ func SettingsPost(c *fiber.Ctx) error {
|
||||
return err
|
||||
}
|
||||
|
||||
c.Redirect("/settings", http.StatusSeeOther)
|
||||
if !noredirect {
|
||||
c.Redirect("/settings", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -238,6 +238,7 @@ textarea[readonly] {
|
||||
max-width: 800px;
|
||||
min-width: 460px;
|
||||
padding: 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
.form-field header {
|
||||
margin: 1.5rem 0;
|
||||
|
||||
@@ -278,6 +278,7 @@ textarea[readonly] {
|
||||
max-width: 800px;
|
||||
min-width: 460px;
|
||||
padding: 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
|
||||
header {
|
||||
margin: 1.5rem 0;
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<h2>Comments</h2>
|
||||
{{ if Illust.CommentDisabled == 1 }}
|
||||
<p>The creator turned comments off</p>
|
||||
{{ else if Illust.Comments == 0 }}
|
||||
<p>There are no comments yet</p>
|
||||
{{ else }} {{ range Illust.CommentsList }}
|
||||
<div class="comment">
|
||||
<a href="/users/{{ .AuthorID }}" class="comment-author">
|
||||
<a href="/users/{{ .AuthorID }}" class="comment-author">
|
||||
<img class="comment-avatar" src="{{ .Avatar }}" alt="{{ .AuthorName }}" />
|
||||
</a>
|
||||
<div class="comment-context">
|
||||
|
||||
@@ -69,11 +69,11 @@
|
||||
</label>
|
||||
<div class="dropdown-content">
|
||||
<div>Font type</div>
|
||||
<form action="{{ url }}" method="post">
|
||||
<form action="{{ url }}?noredirect=t" method="post">
|
||||
<input type="text" name="font-type" value="gothic" class="value-holder" />
|
||||
<input type="submit" value="Gothic" />
|
||||
</form>
|
||||
<form action="{{ url }}" method="post">
|
||||
<form action="{{ url }}?noredirect=t" method="post">
|
||||
<input type="text" name="font-type" value="mincho" class="value-holder" />
|
||||
<input type="submit" value="Mincho" />
|
||||
</form>
|
||||
@@ -88,11 +88,11 @@
|
||||
</label>
|
||||
<div class="dropdown-content">
|
||||
<div>Force text orientation</div>
|
||||
<form action="{{ url }}" method="post">
|
||||
<form action="{{ url }}?noredirect=t" method="post">
|
||||
<input type="text" name="view-mode" value="1" class="value-holder" />
|
||||
<input type="submit" value="Horizontal" />
|
||||
</form>
|
||||
<form action="{{ url }}" method="post">
|
||||
<form action="{{ url }}?noredirect=t" method="post">
|
||||
<input type="text" name="view-mode" value="2" class="value-holder" />
|
||||
<input type="submit" value="Vertical" />
|
||||
</form>
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
<h2>Current cookie values</h2>
|
||||
</summary>
|
||||
<div>
|
||||
<h3>Cookie list</h3>
|
||||
Please note that some cookies here such as ShowArtR18,
|
||||
ShowArtR18G, and ShowArtAI are for features still under development.
|
||||
</div>
|
||||
<p>
|
||||
{{ range CookieList }}
|
||||
<div class="settings-set-cookie">
|
||||
<h3>{{.Key}}</h3>
|
||||
@@ -21,9 +21,24 @@
|
||||
<input type="text" name="value" value="{{.Value}}" />
|
||||
<input type="submit" value="Set" />
|
||||
</form>
|
||||
|
||||
</div>
|
||||
{{ end }}
|
||||
<div>
|
||||
|
||||
<h3>Raw settings</h3>
|
||||
<p>
|
||||
You can save your current cookie values to quickly set your settings on other compatible instances,
|
||||
or if the current instance's cookies went expired.
|
||||
</p>
|
||||
<p>Invalid values will be ignored.</p>
|
||||
<form action="/settings/raw" method="post">
|
||||
<textarea name="raw" rows="10" cols="80">{{range CookieList}}
|
||||
{{.Key}}={{.Value}}{{end}}
|
||||
</textarea>
|
||||
<input type="submit" value="Set raw settings" />
|
||||
</form>
|
||||
</div>
|
||||
</details>
|
||||
<form action="/settings/reset-all" method="post">
|
||||
<input class="critical" type="submit" value="Reset all cookies/preferences" />
|
||||
@@ -34,9 +49,10 @@
|
||||
<ul>
|
||||
<li>Discovery page</li>
|
||||
<li>Landing page</li>
|
||||
<li>Like/Bookmark</li>
|
||||
</ul>
|
||||
<p>
|
||||
Log in with your account's cookie to access the Discovery and Landing pages.
|
||||
Log in with your Pixiv account's cookie to access features above.
|
||||
To learn how to obtain your cookie, please see
|
||||
<a href="https://pixivfe.pages.dev/obtaining-pixivfe-token/">the guide on obtaining your PixivFE token</a>.
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user