knot126

furries, computers, magic

  • they/them (any are fine)


// ==UserScript==
// @name        New script - furaffinity.net
// @namespace   FAJAX
// @match       https://www.furaffinity.net/view/*
// @grant       none
// @version     1.0
// @author      -
// @description 21/09/2023, 02:36:49
// ==/UserScript==

function ajaxify_fav_button() {
  let elements = document.getElementsByClassName("fav");

  for (e of elements) {
    let link = e.children[0];
    let favURL = link.href;

    console.log(favURL);

    link.onclick = function () {
      let f = async function () {
        let result = await fetch(favURL);
        console.log(result);
        link.innerHTML = (link.innerHTML == "+ Fav") ? "βœ“ Faved" : "βœ“ Unfaved";
        link.onclick = function () {};
      }

      f();
    }

    link.style.cursor = "pointer";
    link.removeAttribute("href");
  }
}

ajaxify_fav_button();

console.log("fajax");

this only works the first time you click the button on a page load, but you don't typically unfav right after a fav so im not concerned about it. also excuse i suck at js. and technically its the fetch api. oh and why the fuck don't they just do this by default???


You must log in to comment.