NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name FA - Select YCH and Stream notices
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Selects YCH and Stream notice submissions and journals so you can delete them faster.
// @author Carl Foxmarten
// @match https://www.furaffinity.net/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
var notify = function(text){
var div = document.createElement("div");
div.style.border = "1px solid black";
div.style.borderBottom = "none";
div.style.backgroundColor = "#ffc";
div.style.color = "black";
div.style.borderTopLeftRadius = div.style.borderTopRightRadius = "0.4em";
div.style.left = "50%";
div.style.transform = "translateX(-50%)";
div.style.bottom = "0";
div.style.position = "fixed";
div.style.paddingTop = "3px";
div.style.paddingLeft = div.style.paddingRight = "9px";
div.innerText = text;
document.body.appendChild(div);
};
// The regular expressions to match go here:
const matcher_caps = /.*YCH.*/;
const matcher_insens = /.*(streaming|adopt|closed).*/i;
/*
The goal of this script is to add a button to select all the YCH and Streaming reminder submissions.
- Add a panel (somewhere) to have a button to do this.
Optional:
- Add an option to automatically do this, by setting a cookie.
- Refresh said cookie whenever the page is loaded.
*/
// The root element:
var relem = document.createElement("DIV");
// Add button for "Select YCHs and Streams"
relem.innerHTML = "<button class=\"standard\" type=\"button\" value=\"YCH-streams\" id=\"ych\">YCH&<span class=\"hideontablet hideondesktop\"><br></span>Streams</button>";
// If this is the Submissions page:
if (document.location.pathname.indexOf("/msg/submissions") == 0)
{
var sections = document.getElementsByClassName("section-body");
var section = sections[sections.length-1].children[1];
section.insertBefore(relem.firstElementChild, section.childNodes[0]);
var btn = document.getElementById("ych");
btn.addEventListener("click", function (e){
// Select all the YCH and Stream submissions
var submissions = document.getElementsByTagName("figure");
var name, count=0;
for (var i=0; i < submissions.length; i++)
{
name = submissions[i].querySelector("label p a").innerText;
if (name.match(matcher_caps) != null || name.match(matcher_insens) != null)
{
// This is a match, make sure it's checked.
submissions[i].querySelector("label input[type=checkbox]").checked = true;
submissions[i].className += " checked";
++count;
}
}
if (count > 0)
{
// TODO: We had matches, give a warning.
notify(`Found ${count} submissions.`);
}
return false;
}, true);
}
else if (document.location.pathname.indexOf("/msg/others") == 0)
{
// If this is the Other Messages page:
section = document.getElementById("messages-journals").querySelector(".section-header .section_controls");
section.insertBefore(relem.firstElementChild, section.childNodes[1]);
btn = document.getElementById("ych");
btn.addEventListener("click", function (e){
// Select all the YCH and Stream journals
var submissions = document.querySelectorAll("#messages-journals li");
var name, count=0;
for (var i=0; i < submissions.length; i++)
{
name = submissions[i].querySelector(".journal_subject").innerText;
if (name.match(matcher_caps) != null || name.match(matcher_insens) != null)
{
// This is a match, make sure it's checked
submissions[i].querySelector("input[type=checkbox]").checked = true;
submissions[i].className += " checked";
++count;
}
}
if (count > 0)
{
// TODO: We had matches, give a warning.
notify(`Found ${count} journals.`);
}
return false;
}, true);
} // end if (Submissions/Others)
// Any other page, don't do anything.
})();