-
-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Scene Page Remember States plugin #261
base: main
Are you sure you want to change the base?
Conversation
version: 0.1 | ||
ui: | ||
requires: | ||
- stashUserscriptLibrary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stashUserscriptLibrary
is no longer part of the CommunityScripts repository. It was replaced with https://github.com/stashapp/CommunityScripts/tree/main/plugins/CommunityScriptsUILibrary, but it might be lacking some functionality.
Needs a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As stated by DogmaDragon, still references deprecated StashUserscriptLibrary calls
function main() { | ||
nav(), handlePageDivider(); | ||
} | ||
stash.addEventListener("stash:page:scene", main()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced by PathElementListener
csLib.PathElementListener("/scene/", "", main))
@@ -0,0 +1,101 @@ | |||
(async function waitForStash() { | |||
while (!window.stash) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
window.stash is never exposed and being a requirement should ensure it's loaded beforehand
} | ||
|
||
function handlePageDivider() { | ||
waitForElementClass("scene-tabs order-xl-first order-last", function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see other waitForElement comment
} | ||
|
||
function nav() { | ||
waitForElementClass("mr-auto nav nav-tabs", function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitForElement(".mr-auto.nav.nav-tabs", function() {
{ name: "Edit", key: "scene-edit-panel" }, | ||
]; | ||
|
||
const detailsNav = document.getElementsByClassName( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see other WaitForElement comment
const detailsNav = document.getElementsByClassName( | ||
"mr-auto nav nav-tabs" | ||
)[0]; | ||
const hrefs = detailsNav.getElementsByTagName("a"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see other waitForElement comment
This plugin uses local storage in the browser, to remember last active nav tab of the scenes' detail panel and upon page load activate it, so it's the current panel shown.
It also remembers the active state of the divider collapse button and if true on page load will simulate a click to collapse, so the scene player takes up the full width of the page.