Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

elkorol
Copy link
Contributor

@elkorol elkorol commented Feb 22, 2024

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.

@DogmaDragon DogmaDragon changed the title Added Plugin Add Scene Page Remember States plugin Feb 25, 2024
version: 0.1
ui:
requires:
- stashUserscriptLibrary
Copy link
Contributor

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.

Copy link
Collaborator

@feederbox826 feederbox826 left a 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());
Copy link
Collaborator

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) {
Copy link
Collaborator

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 () {
Copy link
Collaborator

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 () {
Copy link
Collaborator

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(
Copy link
Collaborator

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");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see other waitForElement comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants