From 0b9e79c27dda6d3e97fc539aafb1d650216bab00 Mon Sep 17 00:00:00 2001 From: Ryahn Date: Wed, 20 Nov 2024 16:55:27 -0600 Subject: [PATCH] Add rule 7 api --- quick-promoter.js | 48 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/quick-promoter.js b/quick-promoter.js index de77227..cab35d8 100644 --- a/quick-promoter.js +++ b/quick-promoter.js @@ -1,26 +1,29 @@ // ==UserScript== // @name Promote Current Time // @namespace http://tampermonkey.net/ -// @version 0.5.5 +// @version 0.6.0 // @description Enter the current time for promotion. // @author Gameil // @match https://f95zone.to/threads/*/ // @icon https://www.google.com/s2/favicons?domain=f95zone.to -// @grant none +// @grant GM_xmlhttpRequest // @updateURL 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== (function () { - //devs banned from promotion, add or remove dev names to update the list. - const bannedList = ['1UP Games', 'AnimArts', 'Bawdy Ink Slinger', 'Beachside Bunnies', 'Black Studios', - 'Blue Dragon Studios', 'CutePercentage', 'DEVOLUTION', 'DotArt', 'Holy-Rascals', - 'MaxCoffee', 'Mrvision', 'Naykid', 'Sylver Games', 'Eromancer', 'SC', 'Selebus', - 'SuccuDev', 'Voracity', 'Vortex Cannon Entertainment', 'ZnelArts', 'Zimon']; + let token = localStorage.getItem('api-token'); + + if (!token) { + token = prompt('Please enter API token from Rule7 App'); + localStorage.setItem('api-token', token); + } + var devName = ''; //search dev name const title = document.getElementsByClassName('p-title-value')[0] + let devBanned = false; if(title){ const game_name_ele = title.lastChild; const game_name = game_name_ele.textContent; @@ -36,6 +39,35 @@ game_name_ele.textContent = game_name.slice(0, dev_name_index); title.appendChild(dev_with_link); } + + const pattern = /^(.+?) \[(.+?)\](?: ?\[(.+?)\])?$/ + const titleData = game_name.match(pattern); + const searchDevName = titleData[3] || 'NONE'; + const searchthreadId = document.URL.split('/')[4].split('.')[1]; + + 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 (data) { + 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 @@ -106,7 +138,7 @@ return; } - else if ( bannedList.includes(devName)) { //banned from promo check + else if (devBanned) { //banned from promo check messageBlock.textContent = "The developer is banned from promotion."; messageBlock.style.color = "Red";