// ==UserScript== // @name Stash Video Compare Userscript // @description Userscript for Stash // @match http://192.168.1.2:9999/* // @match http://192.168.1.2:9998/* // @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.1 // @author Scruffynerf / AnonTester // ==/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() { if (window.location.pathname == "/sceneDuplicateChecker") { var numberOfChecked = document.querySelectorAll('input.position-static[type="checkbox"]:checked').length; if (numberOfChecked == 2) { var lr = [] const list = document.querySelectorAll('input[type="checkbox"].position-static:checked') for (let item of list) { const row = item.closest('tr'); const nextAnchor = row.querySelector('a'); const url = nextAnchor.getAttribute('href').replace(/\/scenes\//g, '/scene/') lr.push(window.location.origin.concat(url)) } var site = "http://scruffynerf.stashapp.cc" var url = site.concat("?leftVideoUrl=", lr[0], "/stream&rightVideoUrl=", lr[1], "/stream&hideHelp=1") GM_openInTab(url, true); } } else { 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&hideHelp=1") GM_openInTab(url, true); } } } })();