updates and release
Added better checking and release of r7 checker
This commit is contained in:
parent
cf34b50cf1
commit
7593c6620d
13
Changelog.md
13
Changelog.md
@ -1,3 +1,10 @@
|
|||||||
## 0.6.1
|
|
||||||
### Quick Promoter
|
## Quick Promoter
|
||||||
- Fixed issue where you couldn't promote any thread due to saying Dev is banned from promotion
|
### 0.6.1
|
||||||
|
- Fixed issue where you couldn't promote any thread due to saying Dev is banned from promotion
|
||||||
|
### 0.6.2
|
||||||
|
- Added better checking for banned promotion check
|
||||||
|
|
||||||
|
## Rule7 Notify
|
||||||
|
### 0.1.0
|
||||||
|
- Initial release
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Promote Current Time
|
// @name Promote Current Time
|
||||||
// @namespace http://tampermonkey.net/
|
// @namespace http://tampermonkey.net/
|
||||||
// @version 0.6.1
|
// @version 0.6.2
|
||||||
// @description Enter the current time for promotion.
|
// @description Enter the current time for promotion.
|
||||||
// @author Gameil
|
// @author Gameil
|
||||||
// @match https://f95zone.to/threads/*/
|
// @match https://f95zone.to/threads/*/
|
||||||
@ -11,7 +11,7 @@
|
|||||||
// @downloadURL https://git.zonies.xyz/Ryahn/F95Zone-Scripts/raw/branch/main/quick-promoter.js
|
// @downloadURL https://git.zonies.xyz/Ryahn/F95Zone-Scripts/raw/branch/main/quick-promoter.js
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
(function () {
|
(async function () {
|
||||||
let token = localStorage.getItem('api-token');
|
let token = localStorage.getItem('api-token');
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
@ -20,57 +20,63 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var devName = '';
|
var devName = '';
|
||||||
|
|
||||||
//search dev name
|
|
||||||
const title = document.getElementsByClassName('p-title-value')[0]
|
|
||||||
let devBanned = false;
|
let devBanned = false;
|
||||||
if(title){
|
|
||||||
|
// Asynchronous function to check if developer is banned
|
||||||
|
async function checkDevBanned(threadId, token) {
|
||||||
|
try {
|
||||||
|
const response = await new Promise((resolve, reject) => {
|
||||||
|
GM_xmlhttpRequest({
|
||||||
|
method: 'GET',
|
||||||
|
url: `https://rule7.zonies.xyz/api/v1/promotion?thread_id=${threadId}`,
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${token}`,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
onload: resolve,
|
||||||
|
onerror: reject,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
const data = JSON.parse(response.responseText);
|
||||||
|
console.log('API Response:', data);
|
||||||
|
return Array.isArray(data) && data.length !== 0; // true if banned
|
||||||
|
} else {
|
||||||
|
console.error('API Request failed:', response.status, response.statusText);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Request Error:', error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const title = document.getElementsByClassName('p-title-value')[0];
|
||||||
|
|
||||||
|
if (title) {
|
||||||
const game_name_ele = title.lastChild;
|
const game_name_ele = title.lastChild;
|
||||||
const game_name = game_name_ele.textContent;
|
const game_name = game_name_ele.textContent;
|
||||||
const dev_name_index = game_name.lastIndexOf('[');
|
const dev_name_index = game_name.lastIndexOf('[');
|
||||||
|
|
||||||
if(dev_name_index !== -1) {
|
if (dev_name_index !== -1) {
|
||||||
const dev_name = game_name.slice(dev_name_index);
|
const dev_name = game_name.slice(dev_name_index);
|
||||||
const dev_with_link = document.createElement('a');
|
const dev_with_link = document.createElement('a');
|
||||||
devName = dev_name.slice(1,-1);
|
devName = dev_name.slice(1, -1);
|
||||||
dev_with_link.textContent = dev_name;
|
dev_with_link.textContent = dev_name;
|
||||||
dev_with_link.href = 'https://f95zone.to/sam/latest_alpha/#/cat=games/page=1/creator='+devName;
|
dev_with_link.href = 'https://f95zone.to/sam/latest_alpha/#/cat=games/page=1/creator=' + devName;
|
||||||
dev_with_link.style.color = 'inherit';
|
dev_with_link.style.color = 'inherit';
|
||||||
game_name_ele.textContent = game_name.slice(0, dev_name_index);
|
game_name_ele.textContent = game_name.slice(0, dev_name_index);
|
||||||
title.appendChild(dev_with_link);
|
title.appendChild(dev_with_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
const pattern = /^(.+?) \[(.+?)\](?: ?\[(.+?)\])?$/
|
const searchThreadId = document.URL.split('/')[4].split('.')[1];
|
||||||
const titleData = game_name.match(pattern);
|
console.time('Check Dev Banned');
|
||||||
const searchDevName = titleData[3] || 'NONE';
|
devBanned = await checkDevBanned(searchThreadId, token);
|
||||||
const searchthreadId = document.URL.split('/')[4].split('.')[1];
|
console.timeEnd('Check Dev Banned');
|
||||||
|
|
||||||
GM_xmlhttpRequest({
|
|
||||||
method: 'GET', // Change to 'POST' or other HTTP methods as needed
|
|
||||||
url: 'https://rule7.zonies.xyz/api/v1/promotion?thread_id=' + searchthreadId,
|
|
||||||
headers: {
|
|
||||||
'Authorization': `Bearer ${token}`,
|
|
||||||
'Content-Type': 'application/json', // Include if your API requires it
|
|
||||||
},
|
|
||||||
onload: function(response) {
|
|
||||||
if (response.status === 200) {
|
|
||||||
const data = JSON.parse(response.responseText);
|
|
||||||
if (Array.isArray(data) && data.length !== 0) {
|
|
||||||
devBanned = true;
|
|
||||||
}
|
|
||||||
// Handle successful response here
|
|
||||||
} else {
|
|
||||||
console.error('API Request failed:', response.status, response.statusText);
|
|
||||||
// Handle error here
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onerror: function(error) {
|
|
||||||
console.error('Request Error:', error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//promote time button add
|
// Promote time button
|
||||||
const menuLinkBtn = document.querySelectorAll(".menu-linkRow");
|
const menuLinkBtn = document.querySelectorAll(".menu-linkRow");
|
||||||
let promoBtn, currentBtn;
|
let promoBtn, currentBtn;
|
||||||
menuLinkBtn.forEach((el) => {
|
menuLinkBtn.forEach((el) => {
|
||||||
@ -89,7 +95,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createBtn() {
|
function createBtn() {
|
||||||
//creating enter button
|
// Creating enter button
|
||||||
currentBtn = document.createElement("button");
|
currentBtn = document.createElement("button");
|
||||||
currentBtn.type = "button";
|
currentBtn.type = "button";
|
||||||
currentBtn.title = "Enter Current time";
|
currentBtn.title = "Enter Current time";
|
||||||
@ -121,7 +127,7 @@
|
|||||||
const hhInput = document.querySelector('[name="promote_time_hh"]');
|
const hhInput = document.querySelector('[name="promote_time_hh"]');
|
||||||
const mmInput = document.querySelector('[name="promote_time_mm"]');
|
const mmInput = document.querySelector('[name="promote_time_mm"]');
|
||||||
|
|
||||||
const lastpromoteTime = new Date(
|
const lastPromoteTime = new Date(
|
||||||
`${dateInput.value}T${hhInput.value}:${mmInput.value}:00`
|
`${dateInput.value}T${hhInput.value}:${mmInput.value}:00`
|
||||||
);
|
);
|
||||||
const currentTime = new Date();
|
const currentTime = new Date();
|
||||||
@ -130,17 +136,14 @@
|
|||||||
const hour = currentTime.getHours();
|
const hour = currentTime.getHours();
|
||||||
const minute = currentTime.getMinutes();
|
const minute = currentTime.getMinutes();
|
||||||
|
|
||||||
const timeDiff = currentTime.getTime() - lastpromoteTime.getTime();
|
const timeDiff = currentTime.getTime() - lastPromoteTime.getTime();
|
||||||
|
|
||||||
const messageBlock = document.querySelector(".formRow-explain");
|
const messageBlock = document.querySelector(".formRow-explain");
|
||||||
|
|
||||||
if (timeDiff < 60 * 1000){ //do nothing if time was entered recently (less than 60 seconds)
|
if (timeDiff < 60 * 1000) {
|
||||||
return;
|
return; // Do nothing if time was entered recently (less than 60 seconds)
|
||||||
}
|
} else if (devBanned) {
|
||||||
|
messageBlock.textContent = "The developer is banned from promotion.";
|
||||||
else if (devBanned) { //banned from promo check
|
|
||||||
messageBlock.textContent =
|
|
||||||
"The developer is banned from promotion.";
|
|
||||||
messageBlock.style.color = "Red";
|
messageBlock.style.color = "Red";
|
||||||
messageBlock.style.fontSizeAdjust = 0.6;
|
messageBlock.style.fontSizeAdjust = 0.6;
|
||||||
messageBlock.parentNode.parentNode.parentElement.classList.add("shake");
|
messageBlock.parentNode.parentNode.parentElement.classList.add("shake");
|
||||||
@ -149,10 +152,7 @@
|
|||||||
"shake"
|
"shake"
|
||||||
);
|
);
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
} else if (timeDiff < 14 * 24 * 60 * 60 * 1000) {
|
||||||
|
|
||||||
else if (timeDiff < 14 * 24 * 60 * 60 * 1000) { //recent promotion check
|
|
||||||
|
|
||||||
messageBlock.textContent =
|
messageBlock.textContent =
|
||||||
"Warning: This thread was promoted less than two weeks ago.";
|
"Warning: This thread was promoted less than two weeks ago.";
|
||||||
messageBlock.style.color = "yellow";
|
messageBlock.style.color = "yellow";
|
||||||
@ -172,6 +172,7 @@
|
|||||||
messageBlock.style.color = "green";
|
messageBlock.style.color = "green";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let style = document.createElement("style");
|
let style = document.createElement("style");
|
||||||
style.innerHTML = `
|
style.innerHTML = `
|
||||||
.shake {
|
.shake {
|
||||||
|
|||||||
108
rule7-notify.js
Normal file
108
rule7-notify.js
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
// ==UserScript==
|
||||||
|
// @name Rule7 Notify
|
||||||
|
// @namespace http://tampermonkey.net/
|
||||||
|
// @version 0.1.0
|
||||||
|
// @description Notify when a new Rule7 game is found
|
||||||
|
// @author Ryahn
|
||||||
|
// @match https://f95zone.to/threads/*
|
||||||
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=f95zone.to
|
||||||
|
// @grant GM_xmlhttpRequest
|
||||||
|
// @updateURL https://git.zonies.xyz/Ryahn/F95Zone-Scripts/raw/branch/main/rule7-notify.js
|
||||||
|
// @downloadURL https://git.zonies.xyz/Ryahn/F95Zone-Scripts/raw/branch/main/rule7-notify.js
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
(async function() {
|
||||||
|
'use strict';
|
||||||
|
let token = localStorage.getItem('r7-notify-api-token');
|
||||||
|
|
||||||
|
if (!token || token === '' || token === null) {
|
||||||
|
token = prompt('Please enter API token from Rule7 App');
|
||||||
|
localStorage.setItem('r7-notify-api-token', token);
|
||||||
|
}
|
||||||
|
|
||||||
|
const title = document.getElementsByClassName('p-title-value')[0];
|
||||||
|
let game_name, dev_name;
|
||||||
|
if(title){
|
||||||
|
const game_name_ele = title.lastChild;
|
||||||
|
game_name = game_name_ele.textContent;
|
||||||
|
}
|
||||||
|
const pattern = /^(.+?) \[(.+?)\](?: ?\[(.+?)\])?$/
|
||||||
|
const titleData = game_name.match(pattern);
|
||||||
|
|
||||||
|
if (!titleData[1]) {
|
||||||
|
return console.log('[ERR] Game name cannot be parsed');
|
||||||
|
} else if (titleData[3]) {
|
||||||
|
dev_name = titleData[3];
|
||||||
|
} else {
|
||||||
|
dev_name = 'NONE';
|
||||||
|
}
|
||||||
|
|
||||||
|
game_name = titleData[1];
|
||||||
|
|
||||||
|
const isGameBanned = await checkGameBanned(game_name, token);
|
||||||
|
const isDevBanned = await checkDevBanned(dev_name, token);
|
||||||
|
|
||||||
|
if (isGameBanned || isDevBanned) {
|
||||||
|
console.log(`[ERR] Game or Dev is banned`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkGameBanned(game, token) {
|
||||||
|
try {
|
||||||
|
const response = await new Promise((resolve, reject) => {
|
||||||
|
GM_xmlhttpRequest({
|
||||||
|
method: 'GET',
|
||||||
|
url: `https://rule7.zonies.xyz/api/v1/games?game_name=${game}`,
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${token}`,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
onload: resolve,
|
||||||
|
onerror: reject,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
const data = JSON.parse(response.responseText);
|
||||||
|
const isBanned = data.some(item => item.game_name === game);
|
||||||
|
return isBanned;
|
||||||
|
} else {
|
||||||
|
console.error('API Request failed:', response.status, response.statusText);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Request Error:', error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkDevBanned(dev, token) {
|
||||||
|
if (dev === 'NONE') return false;
|
||||||
|
try {
|
||||||
|
const response = await new Promise((resolve, reject) => {
|
||||||
|
GM_xmlhttpRequest({
|
||||||
|
method: 'GET',
|
||||||
|
url: `https://rule7.zonies.xyz/api/v1/games?dev_name=${dev}`,
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${token}`,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
onload: resolve,
|
||||||
|
onerror: reject,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
const data = JSON.parse(response.responseText);
|
||||||
|
const isBanned = data.some(item => item.author === dev);
|
||||||
|
return isBanned;
|
||||||
|
} else {
|
||||||
|
console.error('API Request failed:', response.status, response.statusText);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Request Error:', error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
Loading…
x
Reference in New Issue
Block a user