1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// ==UserScript==
// @name fill prefs piped
// @namespace Violentmonkey Scripts
// @match https://piped.tjkeller.xyz/preferences
// @grant none
// @version 1.0
// @author tjkeller.xyz
// @description 8/16/2024, 6:10:21 PM
// ==/UserScript==
// fill prefs { id: value }
const prefs = {
chkShowWatchOnYouTube: 1,
chkStoreWatchHistory: 1,
chkDeArrow: 1,
ddlDefaultHomepage: "feed",
ddlDefaultQuality: "720",
ddlSkip_intro: "auto",
ddlSkip_poi_highlight: "button",
ddlSkip_filler: "button",
ddlEnabledCodecs: "avc" // last because this change will reload page
}
// trigger with button press, otherwise page will submit-reload loop forever
function createFillPrefButton() {
const firstInput = app.querySelector("#app label")
// div for nesting button for styling
const inputDiv = document.createElement("div")
inputDiv.classList.add("pref")
// button
const fillPrefButton = document.createElement("button")
fillPrefButton.classList.add("btn", "mx-auto", "font-bold")
fillPrefButton.innerText = "Fill Saved Preferences"
inputDiv.appendChild(fillPrefButton)
// insert before first input
firstInput.parentNode.insertBefore(inputDiv, firstInput)
// do the changing
fillPrefButton.addEventListener("click", () => {
for (const [id, value] of Object.entries(prefs)) {
const input = document.getElementById(id)
if (input.type == "checkbox")
input.checked = value
else
input.value = value
// trigger change event to save
input.dispatchEvent(new Event("change", { bubbles: true }))
}
})
}
// wait 1000ms because dynamic loading
setTimeout(createFillPrefButton, 1000)
|