diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2024-08-16 18:49:31 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2024-08-16 18:49:31 -0500 |
commit | baaa4a2f946b13ad4d527163a140fdb56dcf4936 (patch) | |
tree | 6456f61d3cf04901832e902f24d298d80141de15 /misc/piped-preferences.js | |
parent | 8e793e9d239ae9008382e0af07a163eae804ee32 (diff) | |
download | userscripts-baaa4a2f946b13ad4d527163a140fdb56dcf4936.tar.xz userscripts-baaa4a2f946b13ad4d527163a140fdb56dcf4936.zip |
piped prefs script
Diffstat (limited to 'misc/piped-preferences.js')
-rw-r--r-- | misc/piped-preferences.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/misc/piped-preferences.js b/misc/piped-preferences.js new file mode 100644 index 0000000..c8a1f78 --- /dev/null +++ b/misc/piped-preferences.js @@ -0,0 +1,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) |