-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 568ec6f
Showing
12 changed files
with
1,044 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist/local | ||
__pycache__ | ||
stashdb-userscripts.code-workspace |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Changelog |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# StashDB Userscripts | ||
|
||
## [INSTALL USERSCRIPT](dist/public/StashDB%20Userscripts%20Bundle.user.js?raw=1) | ||
|
||
Installation requires a browser extension such as [Violentmonkey](https://violentmonkey.github.io/) / [Tampermonkey](https://www.tampermonkey.net/) / [Greasemonkey](https://www.greasespot.net/). | ||
|
||
> You may remove any unwanted userscripts from the bundle by removing the line that starts with `// @require` that corresponds to the userscript you wish to remove. | ||
![Allow cors - Tamper Monkey](images/allow-cors-tamper-monkey.png?raw=true "Allow cors - Tamper Monkey") | ||
|
||
## Developing | ||
|
||
Each userscript source is split into two files: | ||
* `src/header` - Folder with userscript metadata blocks | ||
* `src/body` - Folder with main script code | ||
|
||
Execute `py build.py` to combine source files and generate: | ||
* a userscript bundle to `dist\local` for local development | ||
* individual userscripts and a bundle to `dist\public` for release | ||
|
||
Build output directories: | ||
* `dist\local` - A userscript bundle with `@require` headers that load the script code from local files (`src/body`) | ||
* `dist\public` - Userscripts with `@require` headers that load the script code from this github repo |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import os | ||
import config | ||
import shutil | ||
from pathlib import Path | ||
|
||
def get_active_branch_name(): | ||
head_dir = Path(".") / ".git" / "HEAD" | ||
with head_dir.open("r") as f: content = f.read().splitlines() | ||
|
||
for line in content: | ||
if line[0:4] == "ref:": | ||
return line.partition("refs/heads/")[2] | ||
|
||
def build(): | ||
ROOTDIR = Path(__file__).parent.resolve() | ||
LIBFILE = "StashDBUserscriptLibrary.js" | ||
GIT_BRANCH = get_active_branch_name() | ||
GITHUB_ROOT_URL = config.GITHUB_ROOT_URL.replace('%%BRANCH%%', GIT_BRANCH) | ||
print('git branch', GIT_BRANCH) | ||
|
||
localbodyfiles = [] | ||
distbodyfiles = [] | ||
distlibfile = os.path.join(GITHUB_ROOT_URL, 'src', LIBFILE) | ||
for file in os.listdir('src/header'): | ||
# headerpath = os.path.join('src/header', file) | ||
# bodypath = os.path.join('src/body', file) | ||
# distpublicpath = os.path.join('dist/public', file) | ||
# header = open(headerpath, 'r').read() | ||
# body = open(bodypath, 'r').read() | ||
|
||
localbodyfiles.append("file://" + os.path.join(ROOTDIR, 'src/body', file)) | ||
distbodyfiles.append(os.path.join(GITHUB_ROOT_URL, 'src/body', file)) | ||
|
||
# header = header.replace("%NAMESPACE%", config.NAMESPACE) \ | ||
# .replace("%LIBRARYPATH%", distlibfile) \ | ||
# .replace("%MATCHURL%", f"{config.SERVER_URL}/*") \ | ||
# .replace("// @require %FILEPATH%\n", "") | ||
# distscript = header + "\n\n" + body | ||
# with open(distpublicpath, 'w') as f: | ||
# f.write(distscript) | ||
# print(distpublicpath) | ||
|
||
localpath = 'dist/local/StashDB Userscripts Development Bundle.user.js' | ||
locallibfile = "file://" + os.path.join(ROOTDIR, 'src', LIBFILE) | ||
with open(localpath, 'w') as f: | ||
f.write(f"""// ==UserScript== | ||
// @name StashDB Userscripts Development Bundle | ||
// @namespace {config.NAMESPACE} | ||
// @description StashDB Userscripts Development Bundle | ||
// @version {config.BUNDLE_VERSION} | ||
// @author 7dJx1qP | ||
// @match {config.SERVER_URL}/* | ||
// @resource IMPORTED_CSS file://{os.path.join(ROOTDIR, 'src')}\scene.css | ||
// @grant unsafeWindow | ||
// @grant GM_setClipboard | ||
// @grant GM_getResourceText | ||
// @grant GM_addStyle | ||
// @grant GM.getValue | ||
// @grant GM.setValue | ||
// @grant GM.listValues | ||
// @grant GM.xmlHttpRequest | ||
// @connect localhost | ||
// @require {locallibfile} | ||
// | ||
// ************************************************************************************************** | ||
// * YOU MAY REMOVE ANY OF THE @require LINES BELOW FOR SCRIPTS YOU DO NOT WANT * | ||
// ************************************************************************************************** | ||
//\n""") | ||
for localbodyfile in localbodyfiles: | ||
f.write(f"// @require {localbodyfile}\n") | ||
f.write("\n// ==/UserScript==\n") | ||
print(localpath) | ||
|
||
distpath = 'dist/public/StashDB Userscripts Bundle.user.js' | ||
with open(distpath, 'w') as f: | ||
f.write(f"""// ==UserScript== | ||
// @name StashDB Userscripts Bundle | ||
// @namespace {config.NAMESPACE} | ||
// @description StashDB Userscripts Bundle | ||
// @version {config.BUNDLE_VERSION} | ||
// @author 7dJx1qP | ||
// @match {config.SERVER_URL}/* | ||
// @resource IMPORTED_CSS https://raw.githubusercontent.com/7dJx1qP/stashdb-userscripts/{GIT_BRANCH}/dist/public/scene.css | ||
// @grant unsafeWindow | ||
// @grant GM_setClipboard | ||
// @grant GM_getResourceText | ||
// @grant GM_addStyle | ||
// @grant GM.getValue | ||
// @grant GM.setValue | ||
// @grant GM.listValues | ||
// @grant GM.xmlHttpRequest | ||
// @connect localhost | ||
// @require {distlibfile} | ||
// | ||
// ************************************************************************************************** | ||
// * YOU MAY REMOVE ANY OF THE @require LINES BELOW FOR SCRIPTS YOU DO NOT WANT * | ||
// ************************************************************************************************** | ||
//\n""") | ||
for distbodyfile in distbodyfiles: | ||
f.write(f"// @require {distbodyfile}\n") | ||
f.write("\n// ==/UserScript==\n") | ||
print(distpath) | ||
|
||
shutil.copyfile('src/scene.css', 'dist/public/scene.css') | ||
|
||
build() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
GITHUB_ROOT_URL = r"https://raw.githubusercontent.com/7dJx1qP/stashdb-userscripts/%%BRANCH%%/" | ||
BUNDLE_VERSION = "0.1.1" | ||
SERVER_URL = "https://stashdb.org" | ||
NAMESPACE = "https://github.com/7dJx1qP/stashdb-userscripts" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// ==UserScript== | ||
// @name StashDB Userscripts Bundle | ||
// @namespace https://github.com/7dJx1qP/stashdb-userscripts | ||
// @description StashDB Userscripts Bundle | ||
// @version 0.1.1 | ||
// @author 7dJx1qP | ||
// @match https://stashdb.org/* | ||
// @resource IMPORTED_CSS https://raw.githubusercontent.com/7dJx1qP/stashdb-userscripts/master/dist/public/scene.css | ||
// @grant unsafeWindow | ||
// @grant GM_setClipboard | ||
// @grant GM_getResourceText | ||
// @grant GM_addStyle | ||
// @grant GM.getValue | ||
// @grant GM.setValue | ||
// @grant GM.listValues | ||
// @grant GM.xmlHttpRequest | ||
// @connect localhost | ||
// @require https://raw.githubusercontent.com/7dJx1qP/stashdb-userscripts/master/src\StashDBUserscriptLibrary.js | ||
// | ||
// ************************************************************************************************** | ||
// * YOU MAY REMOVE ANY OF THE @require LINES BELOW FOR SCRIPTS YOU DO NOT WANT * | ||
// ************************************************************************************************** | ||
// | ||
// @require https://raw.githubusercontent.com/7dJx1qP/stashdb-userscripts/master/src/body\StashDB Copy StashID.user.js | ||
|
||
// ==/UserScript== |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
.stash_id_match a:hover { | ||
background-color: rgba(0, 0, 0, 0.541); | ||
color: #fff !important; | ||
} | ||
|
||
.stash_id_match.search_match { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
align-self: center; | ||
} | ||
|
||
.stash_id_match.scene_match { | ||
position: relative; | ||
margin-left: 10px; | ||
cursor: pointer; | ||
align-self: center; | ||
display: inline; | ||
} | ||
|
||
.match-yes { | ||
color: green; | ||
} | ||
|
||
.match-no { | ||
color: red; | ||
} | ||
|
||
.stash_id_ignored .match-no { | ||
color: yellow; | ||
} | ||
|
||
.stash_id_wanted .match-no { | ||
color: gold; | ||
} | ||
|
||
.stash_id_match svg { | ||
height: 24px; | ||
width: 24px; | ||
} | ||
|
||
.stash-performer-link img { | ||
width: 2rem; | ||
padding-left: 0.5rem; | ||
} | ||
|
||
.scene-performers .stash-performer-link { | ||
padding-right: 0.25rem; | ||
} | ||
|
||
.SearchPage .stash-performer-link img { | ||
width: 2rem; | ||
padding-left: 0rem; | ||
margin-right: 10px; | ||
} | ||
|
||
.stash_id_ignored, | ||
.stash_id_ignored > .card { | ||
background-color: rgba(48, 64, 77, 0.25) !important; | ||
} | ||
|
||
.stash_id_ignored img { | ||
opacity: 0.25; | ||
} | ||
|
||
.settings-box { | ||
padding: 1rem; | ||
margin-bottom: 0; | ||
position: absolute; | ||
right: 0; | ||
z-index: 999; | ||
background-color: inherit; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.