Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name FFBSCRIPT
- // @namespace http://tampermonkey.net/
- // @version 25/01/2023
- // @description Trying to make something a little useful
- // @author Blue
- // @match https://footfetishbooru.booru.org/*
- // @exclude https://footfetishbooru.booru.org/index.php?page=login*
- // @exclude https://footfetishbooru.booru.org/index.php?page=post&s=add*
- // @exclude https://footfetishbooru.booru.org/index.php?page=favorites&s=view&id=*
- // @grant GM_addStyle
- // ==/UserScript==
- unsafeWindow.getUrlVars = getUrlVars;
- unsafeWindow.bluesConfig = {
- scoreCount: true, //Show a score count above posts while searching.
- tagCount: true, //Show tag count above posts while searching.
- uploaderName: true, //Show uploader name above posts while searching.
- imageSizeFIX: true, //Attempt to prevent huge posts. may break NOTES!
- sauceNAO: true, //Adds the sauceNAO link on posts when it can.
- sauceURL: true, //Turns the sauce per post into a URL, imporoper urls will be broken links.
- };
- function getUrlVars(url) { //Nicked
- var hash;
- var myJson = {};
- var hashes = url.slice(url.indexOf('?') + 1).split('&');
- for (var i = 0; i < hashes.length; i++) {
- hash = hashes[i].split('=');
- myJson[hash[0]] = hash[1];
- // If you want to get in native datatypes
- // myJson[hash[0]] = JSON.parse(hash[1]);
- }
- return myJson;
- }
- (function() {
- 'use strict';
- const config = unsafeWindow.bluesConfig;
- console.log("Script By Blue"); //Also shows it has loaded
- //OTHER
- if (config.sauceURL) {
- try {
- if (document.body.innerHTML.includes("\n Source: ")) { //Making sure I don't break other pages
- var sauce = document.body.innerHTML.split("\n Source: ").pop().split(" <br")[0];
- console.log("Sauce: " + sauce); //This is to find a sauce to a post.
- if (sauce) {
- document.getElementsByTagName("ul")[1].innerHTML = document.getElementsByTagName("ul")[1].innerHTML.replace(sauce, "<a href=\"" + sauce + "\">" + sauce + "</a>"); //Replace the sauce with an actual href to the sauce.
- }
- }
- } catch {}
- }
- if (config.sauceNAO) {
- if (document.body.innerHTML.includes('<img alt="img" src="')) {
- var source = document.body.innerHTML.split('<img alt="img" src="').pop().split("\"")[0];
- console.log("Source: " + source); //This is to find a source to a post image.
- }
- for (let i = 0; i < document.getElementsByTagName("li").length; i++) {
- if (document.getElementsByTagName("li")[i].innerHTML == "<br><br><br><br><br><br><br><br>") {
- document.getElementsByTagName("li")[i].innerHTML = '<li><br><a href=\"https://saucenao.com/search.php?url=' + source + '">[SauceNAO]</a><br><br><br><br><br><br></li>';
- }
- };
- }
- //Resize Images etc
- if (config.imageSizeFIX) {
- if (document.getElementById("image")) {
- document.getElementById("image").style.width = "auto";
- document.getElementById("image").style["max-width"] = "80%";
- }
- if (document.getElementById("note-container")) {
- document.getElementById("note-container").style.width = "auto";
- }
- if (document.getElementsByClassName("sidebar")[0]) { //Tags List
- document.getElementsByClassName("sidebar")[0].style.width = "auto";
- document.getElementsByClassName("sidebar")[0].style["max-width"] = "20%";
- }
- }
- //Get artist
- var tags = " " + document.getElementById("tags").innerText + " "
- var artist = document.getElementById("tags").innerText.split(" ")[document.getElementById("tags").innerText.split("_(artist) ")[0].split(" ").length - 1].split("_(artist)")[0];
- if(tags.indexOf("_(artist) ") > -1) {
- var artistTagNo = document.getElementById("tags").innerText.split("_(artist) ")[0].split(" ").length - 1;
- var artistTag = document.getElementById("tag_list").childNodes[3].children[artistTagNo];
- var artistNo = artistTag.innerHTML.split("</a> ")[1].split("</span>")[0];
- console.log(artist, artistTagNo, artistTag);
- artistTag.hidden = true;
- document.getElementById("tag_list").innerHTML = `<h6>Artist</h6><ul><li><span>? <a style="color: #9093ff;" href="index.php?page=post&s=list&tags=${artist}_(artist)">${artist}</a> ${artistNo}</span></li></ul>` + document.getElementById("tag_list").innerHTML;
- }
- if (
- config.scoreCount ||
- config.tagCount ||
- config.uploaderName
- ) {
- //Adding styles
- GM_addStyle('.ratingnumber {font-size:12px;background-color:#2A2A2A;line-height: 16px;text-align: center;color:#2DBAE5;z-index: 2;border-radius: 3px;position: absolute;left: 15px; top: 15px;}');
- GM_addStyle('.tagcountnumber {font-size:12px;background-color:#2A2A2A;line-height: 16px;text-align: center;color:#2DBAE5;z-index: 2;border-radius: 3px;position: absolute;left: 15px;bottom: 30px;}');
- GM_addStyle('.uploadername {font-size:12px;background-color:#2A2A2A;line-height: 16px;text-align: center;color:#2DBAE5;z-index: 2;border-radius: 3px;position: absolute;left: 15px;bottom: 15px;}');
- GM_addStyle('.remove {font-size:12px;background-color:#A22A2A;line-height: 16px;text-align: center; z-index: 2;border-radius: 3px;position: absolute;left: 15px;bottom: 00px;}');
- GM_addStyle('.thumb {display: inline-block;background-color:#333;border-radius: 30px;position: relative;text-align: center;padding-top: 20px; padding-bottom: 0px;margin-bottom: 5px;margin-right: 10px;}');
- document.getElementsByClassName("thumb").forEach(p => {
- var uploaderName = ""
- var postID = p.firstChild.id.substr(1)
- try {
- uploaderName = p.children[1].firstChild.data.split(`, 'user':'`).pop().split(`'}\n`)[0] || "";
- } catch {
- uploaderName = p.firstChild.firstChild.title.split(' user:').pop().split(' ')[0];
- }
- if (config.scoreCount) {
- p.innerHTML += `<span class="ratingnumber">${p.firstChild.firstChild.title.split('score:').pop().split(' ')[0]}</span>`;
- }
- if (config.tagCount) {
- var tagCount = (p.firstChild.firstChild.title.split(' score:')[0].split(' ').length - 2);
- p.innerHTML += `<span class="tagcountnumber">T:${tagCount}</span>`;
- if(tagCount < 5){p.style="background-color:#dd0";}
- }
- if (uploaderName && config.uploaderName) {
- p.innerHTML += `<span class="uploadername"><a href="https://footfetishbooru.booru.org/index.php?page=account_profile&uname=${uploaderName}">U/${uploaderName}</a></span>`;
- }
- });
- //Sorts a glitch on profiles
- document.getElementsByClassName("ratingnumber").forEach(x => {
- if (x.children.length > 0) {
- x.firstChild.remove()
- }
- });
- document.title = "FFB";
- switch (getUrlVars(document.URL)?.s) { //Stuff
- case "list": //Exploring posts
- document.onkeydown = checkKey;
- break;
- default:
- }
- function checkKey(e) {
- if(document.activeElement.nodeName != "INPUT"){ //Checks if key is pressed OUTSIDE of an input to avoid triggering while you type or edit tags etc
- var pid = window.location.href.split("&pid=")[1] || 0;
- e = e || window.event;
- var newPid = 0;
- switch (e.keyCode) {
- case 37: //Left Arrow
- newPid = pid - 20
- if (newPid > -1) {
- window.location.href=(window.location.href.split("&pid=")[0] + "&pid=" + newPid)
- }
- break;
- case 39: //Right Arrow
- newPid = pid - -20
- window.location.href=(window.location.href.split("&pid=")[0] + "&pid=" + newPid)
- break;
- default:
- //console.log(e.keyCode)
- }
- }
- }
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement