Skip to content

Commit

Permalink
implement TetraxUserscriptLibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetrax-10 committed Jun 16, 2024
1 parent b114c8d commit 2612778
Show file tree
Hide file tree
Showing 10 changed files with 811 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default async () => {
while (!window.stash) {
while (!window.tetraxUSL?.page) {
await new Promise((resolve) => setTimeout(resolve, 100))
}

async function selectUpdatableItems() {
await stash.waitForElement(".package-update-available .form-check > input", 10000, document.body, true)
await tetraxUSL.page.waitForElement(".package-update-available .form-check > input", 10000, document.body, true)

const updatableItems = document.querySelectorAll(".package-update-available .form-check > input")
const tableBody = document.querySelector(".installed-packages tbody")
Expand All @@ -21,8 +21,8 @@ export default async () => {
})
}

stash.addEventListeners(["stash:page:settings:metadata-providers", "stash:page:settings:plugins"], async () => {
const checkForUpdatesButton = await stash.waitForElement(".installed-packages .btn.btn-primary", 3000, document.body, true)
tetraxUSL.page.addEventListeners(["stash:page:settings:metadata-providers", "stash:page:settings:plugins"], async () => {
const checkForUpdatesButton = await tetraxUSL.page.waitForElement(".installed-packages .btn.btn-primary", 3000, document.body, true)
if (checkForUpdatesButton) {
checkForUpdatesButton.addEventListener("click", () => {
selectUpdatableItems()
Expand Down
2 changes: 0 additions & 2 deletions Plugins/AutoSelectUpdatablePluginsAndScrapers/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ ui:
javascript: AutoSelectUpdatablePluginsAndScrapers.js
requires:
- TetraxUserscriptLibrary
- id: StashUserscriptLibrary
source: https://stashapp.github.io/CommunityScripts/stable/index.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default async () => {
while (!window.stash) {
while (!window.tetraxUSL?.utils) {
await new Promise((resolve) => setTimeout(resolve, 100))
}

Expand All @@ -11,7 +11,7 @@ export default async () => {

async function getUpdateablePlugins() {
try {
const pluginsStatus = await stash.callGQL({
const pluginsStatus = await tetraxUSL.utils.callGQL({
operationName: "InstalledPluginPackagesStatus",
variables: {},
query: `
Expand Down Expand Up @@ -49,7 +49,7 @@ export default async () => {

async function updatePlugins(packages) {
try {
await stash.callGQL({
await tetraxUSL.utils.callGQL({
operationName: "UpdatePluginPackages",
variables: {
packages: packages,
Expand All @@ -66,7 +66,7 @@ export default async () => {

async function getUpdateableScrapers() {
try {
const scraperStatus = await stash.callGQL({
const scraperStatus = await tetraxUSL.utils.callGQL({
operationName: "InstalledScraperPackagesStatus",
variables: {},
query: `
Expand Down Expand Up @@ -104,7 +104,7 @@ export default async () => {

async function updateScrapers(packages) {
try {
await stash.callGQL({
await tetraxUSL.utils.callGQL({
operationName: "UpdateScraperPackages",
variables: {
packages: packages,
Expand Down
2 changes: 0 additions & 2 deletions Plugins/AutoUpdatePluginsAndScrapers/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ ui:
javascript: AutoUpdatePluginsAndScrapers.js
requires:
- TetraxUserscriptLibrary
- id: StashUserscriptLibrary
source: https://stashapp.github.io/CommunityScripts/stable/index.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default async () => {
while (!window.stash) {
while (!window.tetraxUSL?.page) {
await new Promise((resolve) => setTimeout(resolve, 100))
}

async function injectVideosAsPreview(timeOut) {
await stash.waitForElement(".scene-card-preview-video", timeOut, document.body, true)
await tetraxUSL.page.waitForElement(".scene-card-preview-video", timeOut, document.body, true)

const allPreviewElement = document.querySelectorAll(".scene-card-preview-video")
allPreviewElement.forEach((element) => {
Expand All @@ -16,7 +16,7 @@ export default async () => {
})
}

stash.addEventListeners(["stash:page:scenes:grid", "stash:page:any:scenes:grid"], () => {
tetraxUSL.page.addEventListeners(["stash:page:scenes:grid", "stash:page:any:scenes:grid"], () => {
injectVideosAsPreview(5000)
})
}
2 changes: 0 additions & 2 deletions Plugins/PlayVideoIfPreviewNotFound/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ ui:
javascript: PlayVideoIfPreviewNotFound.js
requires:
- TetraxUserscriptLibrary
- id: StashUserscriptLibrary
source: https://stashapp.github.io/CommunityScripts/stable/index.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
export default async () => {
while (!window.stash) {
while (!window.tetraxUSL?.page) {
await new Promise((resolve) => setTimeout(resolve, 100))
}

async function replaceThumbnailsWithImages(timeOut, className) {
await stash.waitForElement(className, timeOut, document.body, true)
await tetraxUSL.page.waitForElement(className, timeOut, document.body, true)

const allThumbnailElement = document.querySelectorAll(className)
allThumbnailElement.forEach((element) => {
element.src = element.src.replace("/thumbnail", "/image")
})
}

stash.addEventListeners(["stash:page:images:grid", "stash:page:any:images:grid", "stash:page:gallery", "stash:page:gallery:add", "stash:page:home"], () => {
tetraxUSL.page.addEventListeners(["stash:page:images:grid", "stash:page:any:images:grid", "stash:page:gallery", "stash:page:gallery:add", "stash:page:home"], () => {
replaceThumbnailsWithImages(5000, ".image-card-preview-image")
})
stash.addEventListeners(["stash:page:galleries:grid", "stash:page:any:galleries:grid", "stash:page:home"], () => {
tetraxUSL.page.addEventListeners(["stash:page:galleries:grid", "stash:page:any:galleries:grid", "stash:page:home"], () => {
replaceThumbnailsWithImages(5000, ".gallery-card-image")
})
stash.addEventListeners(["stash:page:galleries:list", "stash:page:any:galleries:list"], () => {
tetraxUSL.page.addEventListeners(["stash:page:galleries:list", "stash:page:any:galleries:list"], () => {
replaceThumbnailsWithImages(5000, ".w-100.w-sm-auto")
})
}
2 changes: 0 additions & 2 deletions Plugins/ReplaceThumbnailsWithImages/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ ui:
javascript: ReplaceThumbnailsWithImages.js
requires:
- TetraxUserscriptLibrary
- id: StashUserscriptLibrary
source: https://stashapp.github.io/CommunityScripts/stable/index.yml
Loading

0 comments on commit 2612778

Please sign in to comment.