Compare commits

..

7 commits

Author SHA1 Message Date
Nicholas Phillips
6fe13acb3c Merge branch 'main' of https://git.bowu.dev/bowu/UserScriptsPublic
All checks were successful
Node.js CI / build (push) Successful in 1m14s
2024-08-03 10:59:32 -04:00
Nicholas Phillips
1e079b9c18 Forgot to add a loop for the warning-proceed.user.js 2024-08-03 10:59:22 -04:00
Nicholas Phillips
d11dfea568 README.md update 2024-08-03 10:58:48 -04:00
Nicholas Phillips
5055253cd3 src/youtube/music/warning-proceed.user.js created 2024-08-03 10:56:36 -04:00
Nicholas Phillips
3cab1d9b59 Recursive building set up. 2024-08-03 10:56:23 -04:00
Nicholas Phillips
e6204dade4 Prettier triggered 2024-08-02 13:17:42 -04:00
Nicholas Phillips
fe681b6017 Copy of https://github.com/pd4d10/userscript-meta/blob/master/index.js 2024-08-02 13:17:35 -04:00
6 changed files with 129 additions and 6 deletions

View file

@ -21,4 +21,12 @@ Because no one wants porn on their monthly statement.
- [src/coomer.su.json](src/coomer.su.json) (contents of https://coomer.su/api/v1/creators.txt)
- [src/coomer.su-modded.json](src/coomer.su-modded.json) (minimal variant)
- [src/kemono.su.json](src/kemono.su.json) (contents of https://kemono.su/api/v1/creators.txt)
- [src/kemono.su-modded.json](src/kemono.su-modded.json) (minimal variant)
- [src/kemono.su-modded.json](src/kemono.su-modded.json) (minimal variant)
## [youtube/music/warning-proceed.user.js](build/youtube/music/warning-proceed.user.js) <small>[(.min.js)](build/youtube/music/warning-proceed.min.user.js)</small>
When listening to music in bed as I read, this prompt could occur at times. Causing me to have to get up to resume whatever mix I was listening to.
![alt text](image-1.png)
This script simply scans and clicks the proceed button.

View file

@ -131,11 +131,23 @@ async function downloadFiles() {
}
async function buildScript(scriptPath) {
const srcDir = path.dirname(scriptPath);
const scriptName = path.basename(scriptPath, ".user.js");
const metaPath = path.join(srcDir, `${scriptName}.meta.js`);
const outPath = path.join(outDir, `${scriptName}.user.js`);
const tempPath = path.join(outDir, `${scriptName}.user.temp.js`);
const minifiedPath = path.join(outDir, `${scriptName}.min.user.js`);
const metaPath = path.join(srcDir, scriptName + `.meta.js`);
let outdDir = [outDir, srcDir.replace(/^src(\\|\/)?/, "")];
const outPath = path.join(...outdDir, `${scriptName}.user.js`);
const tempPath = path.join(...outdDir, `${scriptName}.user.temp.js`);
const minifiedPath = path.join(...outdDir, `${scriptName}.min.user.js`);
console.log({
srcDir,
outdDir,
scriptPath,
scriptName,
metaPath,
outPath,
tempPath,
minifiedPath,
});
if (!fs.existsSync(metaPath)) {
console.error(`Meta file not found: ${metaPath}`);
@ -183,8 +195,11 @@ async function buildScript(scriptPath) {
}
function buildAll() {
const files = fs.readdirSync(srcDir);
const files = fs.readdirSync(srcDir, {
recursive: true,
});
files.forEach((file) => {
console.log(file);
if (file.endsWith(".user.js")) {
buildScript(path.join(srcDir, file));
}

BIN
image-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

74
meta.js Normal file
View file

@ -0,0 +1,74 @@
// This is a copy of https://github.com/pd4d10/userscript-meta/blob/master/index.js
"use strict";
function isUndefined(val) {
return typeof val === "undefined";
}
function isObject(val) {
return typeof val === "object" && val !== null;
}
// Parse metadata to an object
function parse(meta) {
if (typeof meta !== "string") {
throw new Error("`Parse`'s first argument should be a string");
}
return meta
.split(/[\r\n]/)
.filter(function (line) {
// remove blank line
return (
/\S+/.test(line) &&
line.indexOf("==UserScript==") === -1 &&
line.indexOf("==/UserScript==") === -1
);
})
.reduce(function (obj, line) {
var arr = line.trim().replace(/^\/\//, "").trim().split(/\s+/);
var key = arr[0].slice(1);
var value = arr.slice(1).join(" ");
if (isUndefined(obj[key])) {
obj[key] = value;
} else if (Array.isArray(obj[key])) {
obj[key].push(value);
} else {
obj[key] = [obj[key], value];
}
return obj;
}, {});
}
function getLine(key, value) {
// For field which has multiple values, like `match`
if (Array.isArray(value)) {
return value
.map(function (value) {
return getLine(key, value);
})
.join("");
}
return "// @" + key + " " + value + "\n";
}
// Stringify metadata from an object
function stringify(obj) {
if (!isObject(obj)) {
throw new Error("`Stringify`'s first argument should be an object");
}
var meta = Object.keys(obj)
.map(function (key) {
return getLine(key, obj[key]);
})
.join("");
return "// ==UserScript==\n" + meta + "// ==/UserScript==\n";
}
exports.parse = parse;
exports.stringify = stringify;

View file

@ -0,0 +1,8 @@
// ==UserScript==
// @name music.youtube.com
// @description This skips the warning "The following content may contain suicide or self-harm topics." on music.youtube.com
// @namespace Bowud Scripts
// @match https://music.youtube.com/watch*
// @downloadURL {{FILE_URL}}
// @version {{UNIXDATE}}
// ==/UserScript==

View file

@ -0,0 +1,18 @@
setInterval(function () {
let errorScreenEl = document.querySelector("#error-screen");
console.log({ errorScreenEl: errorScreenEl });
let reasonEl = errorScreenEl.querySelector("#reason");
console.log({ reasonEl: reasonEl });
if (
reasonEl.textContent ===
"The following content may contain suicide or self-harm topics."
) {
let buttonEl = errorScreenEl.querySelector(
'button[aria-label="I understand and wish to proceed"]'
);
console.log({ buttonEl: buttonEl });
if (buttonEl) {
buttonEl.click();
}
}
}, 100);