Skip to content

Commit

Permalink
use stash-plugin-builder's dependencyInstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetrax-10 committed Feb 16, 2024
1 parent 1d2bc48 commit 2695b92
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 118 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
export default async () => {
while (!window.TetraxUSL?.stash) {
while (!window.stash) {
await new Promise((resolve) => setTimeout(resolve, 100))
}

const Stash = window.TetraxUSL.stash

async function selectUpdatableItems() {
await Stash.waitForElement(".package-update-available .form-check > input", 10000, document.body, true)
await stash.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 @@ -23,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)
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)
if (checkForUpdatesButton) {
checkForUpdatesButton.addEventListener("click", () => {
selectUpdatableItems()
Expand Down
2 changes: 2 additions & 0 deletions Plugins/AutoSelectUpdatablePluginsAndScrapers/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ 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,10 +1,8 @@
export default async () => {
while (!window.TetraxUSL?.stash) {
while (!window.stash) {
await new Promise((resolve) => setTimeout(resolve, 100))
}

const Stash = window.TetraxUSL.stash

function isDateLater(dateString1, dateString2) {
const date1 = new Date(dateString1)
const date2 = new Date(dateString2)
Expand All @@ -13,7 +11,7 @@ export default async () => {

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

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

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

async function updateScrapers(packages) {
try {
await Stash.callGQL({
await stash.callGQL({
operationName: "UpdateScraperPackages",
variables: {
packages: packages,
Expand Down
2 changes: 2 additions & 0 deletions Plugins/AutoUpdatePluginsAndScrapers/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ 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,12 +1,10 @@
export default async () => {
while (!window.TetraxUSL?.stash) {
while (!window.stash) {
await new Promise((resolve) => setTimeout(resolve, 100))
}

const Stash = window.TetraxUSL.stash

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

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

Stash.addEventListeners(["stash:page:scenes:grid", "stash:page:any:scenes:grid"], () => {
stash.addEventListeners(["stash:page:scenes:grid", "stash:page:any:scenes:grid"], () => {
injectVideosAsPreview(5000)
})
}
2 changes: 2 additions & 0 deletions Plugins/PlayVideoIfPreviewNotFound/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ 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,26 +1,24 @@
export default async () => {
while (!window.TetraxUSL?.stash) {
while (!window.stash) {
await new Promise((resolve) => setTimeout(resolve, 100))
}

const Stash = window.TetraxUSL.stash

async function replaceThumbnailsWithImages(timeOut, className) {
await Stash.waitForElement(className, timeOut, document.body, true)
await stash.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"], () => {
stash.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"], () => {
stash.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"], () => {
stash.addEventListeners(["stash:page:galleries:list", "stash:page:any:galleries:list"], () => {
replaceThumbnailsWithImages(5000, ".w-100.w-sm-auto")
})
}
2 changes: 2 additions & 0 deletions Plugins/ReplaceThumbnailsWithImages/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ ui:
javascript: ReplaceThumbnailsWithImages.js
requires:
- TetraxUserscriptLibrary
- id: StashUserscriptLibrary
source: https://stashapp.github.io/CommunityScripts/stable/index.yml
85 changes: 0 additions & 85 deletions Plugins/TetraxUserscriptLibrary/TetraxUserscriptLibrary.js

This file was deleted.

8 changes: 0 additions & 8 deletions Plugins/TetraxUserscriptLibrary/settings.yml

This file was deleted.

0 comments on commit 2695b92

Please sign in to comment.