Skip to content

Added ability to retrieve a work's workskin#110

Open
Cyberpro54321 wants to merge 5 commits into
wendytg:masterfrom
Cyberpro54321:PR
Open

Added ability to retrieve a work's workskin#110
Cyberpro54321 wants to merge 5 commits into
wendytg:masterfrom
Cyberpro54321:PR

Conversation

@Cyberpro54321

Copy link
Copy Markdown

Added a workskin() function in works.py, which returns the contents of the first <style type:"text/css"> tag it can find. In every case I've checked, that tag (if it exists) will contain the CSS code for the 'workskin', custom theming that authors can put on their works. Returns an empty string if there is no workskin.

@wendytg

wendytg commented Mar 6, 2025

Copy link
Copy Markdown
Owner

Oh, awesome, you wrote this fast! I'll hopefully test it this weekend.

While I have not tested this yet, I suspect there may be an issue if the user is logged in and has a site skin enabled, because in that case, there can be several <style> tags, and they may all be site skins, or the last one may be the workskin. If that happens, then additional checks would be necessary to ensure you're actually getting a workskin inside a style tag, perhaps by checking for the "Hide Creator's Style" button and if it's present, getting the last style tag on the page.

@Cyberpro54321

Cyberpro54321 commented Mar 6, 2025

Copy link
Copy Markdown
Author

Thank you for the fast reply! I previously tested the Site Skins thing and came out of the experience convinced that those were served as a <link rel="stylesheet" href="..."> sort of element, but I just checked and I'm definitely getting it as a <style> element this time. Will start working on the Site Script-compatible version now.

@Cyberpro54321

Copy link
Copy Markdown
Author

If it wasn't clear before I consider the 5th commit from March 5th (71234e4) to be the completed version of the "Site Script-compatible version" I mentioned before. I tested it on fics with and without workskins, both while browsing anonymously and while logged in to my account with a site script enabled, and it behaved as expected in all four cases. Is there anything else you need me to do before this can be merged?

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.

2 participants