Created
September 4, 2023 12:22
-
-
Save DogmaDragon/fb3ed033c0d1f0a6811137dfea0c4ce8 to your computer and use it in GitHub Desktop.
Userscript for Stash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Stash Video Compare Userscript | |
// @description Userscript for Stash | |
// @match *localhost:9999/* | |
// @grant GM_openInTab | |
// @require https://code.jquery.com/jquery-1.12.4.min.js | |
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js | |
// @version 1.0 | |
// @author Scruffynerf | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
console.log('Script Stash initialize'); | |
waitForKeyElements(".navbar-brand", addbutton); | |
function addbutton() { | |
const navBar = document.querySelector(".navbar-nav"); | |
const buttonClass = navBar.firstChild.attributes.class.value; | |
const linkClass = navBar.firstChild.firstChild.attributes.class.value; | |
const newButton = document.createElement("div"); | |
newButton.setAttribute("class", buttonClass); | |
newButton.onclick = compare | |
const innerLink = document.createElement("a"); | |
innerLink.setAttribute("class", linkClass); | |
const buttonLabel = document.createElement("span"); | |
buttonLabel.innerText = "Video Compare"; | |
innerLink.appendChild(buttonLabel); | |
newButton.appendChild(innerLink); | |
navBar.appendChild(newButton); | |
} | |
function compare() { | |
var numberOfChecked = document.querySelectorAll('input[type="checkbox"]:checked').length; | |
if (numberOfChecked == 2) { | |
const r = /[^"]+\/scene\/\d+\/s/ms; | |
var lr = [] | |
const list = document.querySelectorAll('input[type=checkbox]:checked') | |
for (let item of list) { | |
var urlstuff = item.nextElementSibling.innerHTML | |
var m = r.exec(urlstuff) | |
lr.push(m[0]) | |
} | |
var site = "http://scruffynerf.stashapp.cc" | |
var url = site.concat("?leftVideoUrl=", lr[0], "tream&rightVideoUrl=", lr[1], "tream") | |
GM_openInTab(url, true); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
as this doesn't work in the sceneDuplicateChecker admin tool page, I've added a second layout for this and also disabled the help popup. This would be better as an actual plugin for stash incorporating https://github.com/vivictorg/vivict to run without internet access and even better as a modal on the page rather than fullscreen, but I have no idea how to implement that.
Might this is of use to someone.