diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/piped-preferences.js | 76 |
1 files changed, 30 insertions, 46 deletions
diff --git a/misc/piped-preferences.js b/misc/piped-preferences.js index c8a1f78..cfb0233 100644 --- a/misc/piped-preferences.js +++ b/misc/piped-preferences.js @@ -1,59 +1,43 @@ // ==UserScript== // @name fill prefs piped // @namespace Violentmonkey Scripts -// @match https://piped.tjkeller.xyz/preferences +// @match https://piped.tjkeller.xyz/* // @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 +// all skip options (if any are to be set) must be present to avoid player errors +const skipOptionsDefault = { + sponsor: "auto", + intro: "no", + outro: "no", + preview: "no", + interaction: "auto", + selfpromo: "auto", + music_offtopic: "auto", + poi_highlight: "no", + filler: "no" } -// 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 })) - } - }) +// fill localStorage { key: value } with preferred options +// any preferences not filled with be default +const prefs = { + bufferGoal: 30, + dearrow: true, + enabledCodecs: "avc", + homepage: "feed", + quality: 720, + showWatchOnYouTube: true, + watchHistory: true, + skipOptions: JSON.stringify({...skipOptionsDefault, ...{ + intro: "auto", + poi_highlight: "button", + filler: "button", + }}), } -// wait 1000ms because dynamic loading -setTimeout(createFillPrefButton, 1000) +// setup localStorage +for (const [key, value] of Object.entries(prefs)) + localStorage.setItem(key, value) |