feat: add scripts

This commit is contained in:
2023-08-22 01:28:47 +07:00
parent 7fe79a2bdb
commit 92c0e0ee6c
19 changed files with 581 additions and 438 deletions

View File

@ -12,12 +12,16 @@
// @downloadURL https://gitlab.com/tretrauit/scripts/-/raw/main/userscripts/anonyviet-skip-wait.user.js
// ==/UserScript==
const REDIRECT_PAGE = "https://anonyviet.com/tieptucdentrangmoi/?url="
const REDIRECT_PAGE = "https://anonyviet.com/tieptucdentrangmoi/?url=";
for (const element of document.getElementsByTagName("a")) {
try {
if (element.getAttribute("href").startsWith(REDIRECT_PAGE)) {
element.setAttribute("href", decodeURIComponent(element.getAttribute("href").substring(REDIRECT_PAGE.length)))
}
} catch (_) {
try {
if (element.getAttribute("href").startsWith(REDIRECT_PAGE)) {
element.setAttribute(
"href",
decodeURIComponent(
element.getAttribute("href").substring(REDIRECT_PAGE.length),
),
);
}
} catch (_) {}
}

View File

@ -13,16 +13,20 @@
// ==/UserScript==
setTimeout(() => {
const header = document.querySelector(".src-components-common-TopBar-assets-__pc_---top---uiHfPh");
const header = document.querySelector(
".src-components-common-TopBar-assets-__pc_---top---uiHfPh",
);
if (header != null) {
header.remove()
console.log("Removed header")
header.remove();
console.log("Removed header");
}
setTimeout(() => {
const watermark = document.querySelector(".src-components-pages-assets-__kv_---kv-slogan---IBwwuz.kv-slogan");
const watermark = document.querySelector(
".src-components-pages-assets-__kv_---kv-slogan---IBwwuz.kv-slogan",
);
if (watermark != null) {
watermark.remove()
console.log("Removed watermark")
watermark.remove();
console.log("Removed watermark");
}
}, 5000);
}, 5000);

View File

@ -12,25 +12,27 @@
// @downloadURL https://gitlab.com/tretrauit/scripts/-/raw/main/userscripts/hidemy.name-free-ipport-export.user.js
// ==/UserScript==
setTimeout(function() {
const tblContent = document.getElementsByClassName("table_block")[0].getElementsByTagName("tbody")[0].children
setTimeout(function () {
const tblContent = document
.getElementsByClassName("table_block")[0]
.getElementsByTagName("tbody")[0].children;
// Replace the export IP:Port button
const btns = document.getElementsByClassName("export")[0]
const exportBtn = btns.children[0]
const fakeExportBtn = exportBtn.cloneNode(true)
fakeExportBtn.removeAttribute("href")
fakeExportBtn.addEventListener("click", () => {
var proxyStr = ""
for (let proxyContent of tblContent) {
const proxyContentChildren = proxyContent.children
const proxyIp = proxyContentChildren[0].innerHTML
const proxyPort = proxyContentChildren[1].innerHTML
proxyStr += proxyIp + ":" + proxyPort + "\n"
}
navigator.clipboard.writeText(proxyStr)
alert("Copied IP:Port list to clipboard.")
})
exportBtn.remove()
btns.prepend(fakeExportBtn)
// Replace the export IP:Port button
const btns = document.getElementsByClassName("export")[0];
const exportBtn = btns.children[0];
const fakeExportBtn = exportBtn.cloneNode(true);
fakeExportBtn.removeAttribute("href");
fakeExportBtn.addEventListener("click", () => {
var proxyStr = "";
for (let proxyContent of tblContent) {
const proxyContentChildren = proxyContent.children;
const proxyIp = proxyContentChildren[0].innerHTML;
const proxyPort = proxyContentChildren[1].innerHTML;
proxyStr += proxyIp + ":" + proxyPort + "\n";
}
navigator.clipboard.writeText(proxyStr);
alert("Copied IP:Port list to clipboard.");
});
exportBtn.remove();
btns.prepend(fakeExportBtn);
}, 5000);

View File

@ -14,81 +14,88 @@
// ==/UserScript==
function init() {
const chest = document.getElementsByClassName("chest")[0]
const chestStatus = document.getElementsByClassName("chest__btn btn")[0]
const openWheelBtn = document.getElementsByClassName("wheel__btn")[0]
const upgradeBtn = document.getElementsByClassName("card__upgrade")[0]
// Has string characters need to be removed first.
const requiredScore = document.getElementsByClassName("card__note")[0].getElementsByTagName("strong")[0]
const currentScore = document.getElementsByClassName("card__data")[0].getElementsByTagName("span")[1]
const chest = document.getElementsByClassName("chest")[0];
const chestStatus = document.getElementsByClassName("chest__btn btn")[0];
const openWheelBtn = document.getElementsByClassName("wheel__btn")[0];
const upgradeBtn = document.getElementsByClassName("card__upgrade")[0];
// Has string characters need to be removed first.
const requiredScore = document
.getElementsByClassName("card__note")[0]
.getElementsByTagName("strong")[0];
const currentScore = document
.getElementsByClassName("card__data")[0]
.getElementsByTagName("span")[1];
function toInt(str) {
return parseInt(str.replace(/[^0-9]/g, ''))
function toInt(str) {
return parseInt(str.replace(/[^0-9]/g, ""));
}
function upgradeRank() {
if (toInt(currentScore.innerHTML) >= toInt(requiredScore.innerHTML)) {
upgradeBtn.click();
}
}
function upgradeRank() {
if (toInt(currentScore.innerHTML) >= toInt(requiredScore.innerHTML)) {
upgradeBtn.click()
function receiveRankReward() {
const rewards = document.getElementsByClassName("milestone available");
for (const reward of rewards) {
if (reward.className.includes("claimed")) {
continue;
}
reward.click();
}
}
function spinWheel() {
const spinBtn = document.getElementsByClassName("popup-wheel__btn")[0];
const spinLeft = spinBtn.children[1].getElementsByTagName("strong")[0];
function doSpin() {
spinBtn.click();
setTimeout(() => {
if (parseInt(spinLeft.innerHTML) > 0) {
setTimeout(doSpin, 1000);
}
}, 3000);
}
doSpin();
const closeBtn = document.getElementsByClassName("close")[0];
closeBtn.click();
}
function receiveRankReward() {
const rewards = document.getElementsByClassName("milestone available")
for (const reward of rewards) {
if (reward.className.includes("claimed")) {
continue
}
reward.click()
}
function wheel() {
if (
!openWheelBtn.className.includes("animate__tada") ||
document.getElementById("wheel") != null
) {
return;
}
console.log("click chest");
openWheelBtn.click();
setTimeout(spinWheel, 1000);
}
function spinWheel() {
const spinBtn = document.getElementsByClassName("popup-wheel__btn")[0]
const spinLeft = spinBtn.children[1].getElementsByTagName("strong")[0]
function doSpin() {
spinBtn.click()
setTimeout(() => {
if (parseInt(spinLeft.innerHTML) > 0) {
setTimeout(doSpin, 1000)
}
}, 3000)
}
doSpin()
const closeBtn = document.getElementsByClassName("close")[0]
closeBtn.click()
function receiveScore() {
if (chestStatus.innerHTML === "Nhận") {
chest.click();
}
}
function wheel() {
if (!openWheelBtn.className.includes("animate__tada") || document.getElementById("wheel") != null) {
return
}
console.log("click chest")
openWheelBtn.click()
setTimeout(spinWheel, 1000)
setInterval(() => {
if ((element = document.getElementsByClassName("swal2-close")[0])) {
element.click();
}
}, 100);
function receiveScore() {
if (chestStatus.innerHTML === "Nhận") {
chest.click()
}
}
setInterval(() => {
if (element = document.getElementsByClassName("swal2-close")[0]) {
element.click()
}
}, 100);
function loop() {
receiveScore()
upgradeRank()
receiveRankReward()
setTimeout(wheel, 500)
setTimeout(loop, 1000)
}
loop()
function loop() {
receiveScore();
upgradeRank();
receiveRankReward();
setTimeout(wheel, 500);
setTimeout(loop, 1000);
}
loop();
}
setTimeout(init, 5000)
setTimeout(init, 5000);
console.warn("[8thang5 - Auto farm] Successfully loaded")
console.log("Made by @tretrauit under MIT License")
console.warn("[8thang5 - Auto farm] Successfully loaded");
console.log("Made by @tretrauit under MIT License");

View File

@ -13,65 +13,69 @@
// ==/UserScript==
function injectCSS(css) {
const style = document.createElement('style');
const style = document.createElement("style");
style.appendChild(document.createTextNode(css));
document.head.appendChild(style);
}
function findElement(tag, properties) {
const elements = document.querySelectorAll(tag);
elementLoop:
for (const element of elements) {
for (const [key, value] of Object.entries(properties)) {
if (element.getAttribute(key) != value) {
continue elementLoop;
}
}
return element;
const elements = document.querySelectorAll(tag);
elementLoop: for (const element of elements) {
for (const [key, value] of Object.entries(properties)) {
if (element.getAttribute(key) != value) {
continue elementLoop;
}
}
return element;
}
}
function getAncestor(element, level) {
if (element == null) {
return null;
}
for (let i = 0; i < level; i++) {
element = element.parentNode;
}
return element;
if (element == null) {
return null;
}
for (let i = 0; i < level; i++) {
element = element.parentNode;
}
return element;
}
console.log("Scanning class for components...");
// Search box
let searchBox = findElement("input", {"aria-autocomplete": "list"});
let searchBox = findElement("input", { "aria-autocomplete": "list" });
if (searchBox == null) {
console.warn("Failed to get searchBox element.");
throw new Error();
console.warn("Failed to get searchBox element.");
throw new Error();
}
searchBox = getAncestor(searchBox, 7);
// Header & Text header
let textHeader = findElement("span", {"style": "line-height: var(--base-line-clamp-line-height); --base-line-clamp-line-height:28px;"});
let textHeader = findElement("span", {
style:
"line-height: var(--base-line-clamp-line-height); --base-line-clamp-line-height:28px;",
});
let header;
if (textHeader == null) {
console.warn("Failed to get textHeader element.");
throw new Error();
console.warn("Failed to get textHeader element.");
throw new Error();
}
header = getAncestor(textHeader, 7);
textHeader = textHeader.childNodes[0];
// Unread indicator
let unreadIndicator = findElement("span", {"data-visualcompletion": "ignore"});
let unreadIndicator = findElement("span", {
"data-visualcompletion": "ignore",
});
// Action bar
let actionBar = findElement("div", {"aria-expanded": "false"});
let actionBar = findElement("div", { "aria-expanded": "false" });
if (actionBar == null) {
console.warn("Failed to get actionBar element.");
throw new Error();
console.warn("Failed to get actionBar element.");
throw new Error();
}
actionBar = actionBar.parentNode;
// Chats
let chats = findElement("div", {"aria-label": "Chats"});
let chats = findElement("div", { "aria-label": "Chats" });
if (chats == null) {
console.warn("Failed to get chats element.");
throw new Error();
console.warn("Failed to get chats element.");
throw new Error();
}
chats = chats.parentNode;
// Print elements

View File

@ -13,19 +13,24 @@
// ==/UserScript==
// Remove the "download app ads"
const dlClasses = ["tiktok-9er52i-DivCtaGuideWrapper", "tiktok-99ed1t-DivFooterGuide", "tiktok-txik7e-DivFloatButtonWrapper", "tiktok-h0mxry-DivCtaContentWrapper"]
const dlClasses = [
"tiktok-9er52i-DivCtaGuideWrapper",
"tiktok-99ed1t-DivFooterGuide",
"tiktok-txik7e-DivFloatButtonWrapper",
"tiktok-h0mxry-DivCtaContentWrapper",
];
setInterval(() => {
for (const dlClass of dlClasses) {
const element = document.getElementsByClassName(dlClass)[0]
if (element === undefined) {
continue
}
for (const childElm of element.children) {
console.log(childElm)
setTimeout(() => element.removeChild(childElm), 1)
}
element.style["height"] = "0px"
element.style["padding"] = "0px"
element.style["z-index"] = "-1"
for (const dlClass of dlClasses) {
const element = document.getElementsByClassName(dlClass)[0];
if (element === undefined) {
continue;
}
}, 50)
for (const childElm of element.children) {
console.log(childElm);
setTimeout(() => element.removeChild(childElm), 1);
}
element.style["height"] = "0px";
element.style["padding"] = "0px";
element.style["z-index"] = "-1";
}
}, 50);

View File

@ -24,20 +24,19 @@ function logDebug(...kwargs) {
console.log(...kwargs);
}
function getShortsId(videoPathName)
{
const shortPath = videoPathName.split("/")
return shortPath[shortPath.length - 1]
function getShortsId(videoPathName) {
const shortPath = videoPathName.split("/");
return shortPath[shortPath.length - 1];
}
function redirectReplace() {
window.location.replace("https://www.youtube.com/watch?v=" + getShortsId(window.location.pathname));
window.location.replace(
"https://www.youtube.com/watch?v=" + getShortsId(window.location.pathname),
);
}
function checkCurrentURL()
{
if (window.location.pathname.includes("/shorts/"))
{
function checkCurrentURL() {
if (window.location.pathname.includes("/shorts/")) {
logDebug("Shorts url detected, redirecting...");
redirectReplace();
}
@ -46,22 +45,19 @@ function checkCurrentURL()
// Should be run asap
checkCurrentURL();
function replaceHrefURL(element)
{
if (element.href != null && element.href.includes("/shorts/"))
{
element.href = "/watch?v=" + getShortsId(element.href)
function replaceHrefURL(element) {
if (element.href != null && element.href.includes("/shorts/")) {
element.href = "/watch?v=" + getShortsId(element.href);
}
}
function checkElements()
{
insertionQ(':is(#video-title, #thumbnail) ').every(function(element) {
function checkElements() {
insertionQ(":is(#video-title, #thumbnail) ").every(function (element) {
replaceHrefURL(element);
});
}
window.addEventListener('yt-navigate-finish', checkCurrentURL);
window.addEventListener("yt-navigate-finish", checkCurrentURL);
// Replace addEventListener with our sus one.
const o_addEventListener = window.addEventListener;
const o_shady_addEventListener = window.__shady_addEventListener;
@ -89,17 +85,21 @@ function f_addEventListener(eventName, callback) {
// This event is made by SponsorBlock not Youtube so by default it will not run.
// But this can speed up the page navigation process so i'll just keep it.
const data = event.data;
if (data.type == 'navigation' && data.pageType == 'shorts') {
if (data.type == "navigation" && data.pageType == "shorts") {
if (data.videoID == undefined) {
return;
}
logDebug("Thank you SponsorBlock for this event :3");
logDebug("Navigating to video...");
if (window.location.pathname.includes("/shorts/")) {
window.location.replace("https://www.youtube.com/watch?v=" + data.videoID);
window.location.replace(
"https://www.youtube.com/watch?v=" + data.videoID,
);
return;
}
window.location.assign("https://www.youtube.com/watch?v=" + data.videoID);
window.location.assign(
"https://www.youtube.com/watch?v=" + data.videoID,
);
return;
}
}
@ -117,4 +117,4 @@ logDebug("Init fake addEventListener successful.");
window.__shady_addEventListener = f_sus_addEventListener;
logDebug("Init fake __shady_addEventListener successful.");
checkElements();
console.warn("Fuck you YouTube - NoShorts loaded.")
console.warn("Fuck you YouTube - NoShorts loaded.");