// ==UserScript==
// @name FA SubFilter
// @namespace FurAffinity
// @version 3.0.0
// @description Enable/Disable custom submission types with keywords
// @author JaysonHusky
// @grant GM_getValue
// @grant GM_setValue
// @match *://www.furaffinity.net/msg/submissions*
// @match *://www.furaffinity.net/gallery*
// @match *://www.furaffinity.net/favorites*
// @match *://www.furaffinity.net/browse*
// @match *://www.furaffinity.net/controls/user-settings/*
// @require https://code.jquery.com/jquery-latest.js
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
var target_mode="on";
var TemplateStyle=$('body').attr('data-static-path');
if(TemplateStyle===undefined){throw new Error("SubFilter: An error occured. [Code: ERR_TPL_VARS_MIS]");}
// Setup keywords
var SubFilter_Keywords;
var sf_ud_keywords;
// Begin loading
function FASFM_Load(){
sf_ud_keywords=GM_getValue('fasfm');
if(sf_ud_keywords>""){
SubFilter_Keywords=sf_ud_keywords.split(",");
$('#fafsm_settings').val(sf_ud_keywords.replace(/,/g,", "));
}
else {
console.log("SubFilter: An error occured while attempting to retrieve keywords. [Code: ERR_KEYS_UNDEFINED]");
}
}
// Add Special Stylesheet for keywords
var JaysCSS=document.createElement('style');
var jayStyle=document.createTextNode(`
i.fafsm{
margin-right:5px;
padding:1px;
}
span.fafx-update-status{
font-weight:bold;
color:#04fd04;
float:right;
clear:right;
display:none;
}
#customfacontrolpanel{
/*border:1px dashed white;
background:rgba(1,0,0,0.1);
padding:5px;
border-radius:5px;*/
margin-top:20px;
}
.JaySB{
background: #36393d;
padding: 7px 14px 14px 14px;
}
#speciallisting li{
margin-left:20px;
}
`);
JaysCSS.appendChild(jayStyle);
document.getElementsByTagName('body')[0].appendChild(JaysCSS);
// Save settings
function FAFSM_SaveSettings(fasfm){
GM_setValue('fasfm',fasfm);
}
// Load Control Panel
var pathx=window.location.pathname;
if(~pathx.indexOf("/controls/user-settings/")){
// Update
$(document.body).on('click','#fafsm_saveit',function(){
var fafsm_set=$("input[name='fafsm_setting']").val().replace(/ /g,"").replace(/ /g,"");
FAFSM_SaveSettings(fafsm_set);
$('.fafx-update-status').fadeIn('slow');
setTimeout(function(){
$('.fafx-update-status').fadeOut('slow');
}, 5000);
});
if(TemplateStyle=="/themes/beta"){
$('.content .section-body').after(`
SubFilter Control Panel Update successful!
Custom Keywords to blacklist in submissions inbox
*Updates take effect from the next page load.SubFilter (A user controlled FA Blacklisting tool) by JaysonHusky
`);
}
else {
$('.footer').before(`
SubFilter - Control Panel
Update successful!
|
`);
}
}
FASFM_Load();
// Setup the hook
// Adapt JQuery :contains to function without case restriction
jQuery.expr[':'].icontains=function(a,i,m){return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0;};
// JS equiv of PHPs ucwords() for better presentation (Credit: rickycheers @ Github)
String.prototype.ucwords=function(){
st2uc=this.toLowerCase();
return st2uc.replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g,function(s){
return s.toUpperCase();
});
};
function subcount(inp){if(isNaN(inp)===true){return "0";}else{return inp;}}
// Search for custom keywords
if(SubFilter_Keywords===undefined){}
else{
SubFilter_Keywords.forEach(function(keyword){
if(target_mode=="on"){
// Message Center ( Submissions Only )
$("#messagecenter-submissions section figure figcaption").find("label a:icontains('"+keyword+"')").parent().parent().parent().parent().css('display','none');
// User Profile Gallery
$("#gallery-gallery figure figcaption").find("a:icontains('"+keyword+"')").parent().parent().parent().css('display','none');
// User Profile Favourites
$("#gallery-favorites figure figcaption").find("a:icontains('"+keyword+"')").parent().parent().parent().css('display','none');
// Browse Page
$("#gallery-browse figure figcaption").find("a:icontains('"+keyword+"')").parent().parent().parent().css('display','none');
// Deactivate on Search page as the user can filter by themselves there.
}
else {
// Message Center ( Submissions Only )
$("#messagecenter-submissions section figure figcaption").find("label p:first a:icontains('"+keyword+"')").parent().parent().parent().parent().css('display','none');
// User Profile Gallery
$("#gallery-gallery figure figcaption").find("p:first a:icontains('"+keyword+"')").parent().parent().parent().css('display','none');
// User Profile Favourites
$("#gallery-favorites figure figcaption").find("p:first a:icontains('"+keyword+"')").parent().parent().parent().css('display','none');
// Browse Page
$("#gallery-browse figure figcaption").find("p:first a:icontains('"+keyword+"')").parent().parent().parent().css('display','none');
// Deactivate on Search page as the user can filter by themselves there.
}
});
}
})(); |