Skip to content

Instantly share code, notes, and snippets.

@thelink2012
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thelink2012/65db658df10a4d94da17 to your computer and use it in GitHub Desktop.
Save thelink2012/65db658df10a4d94da17 to your computer and use it in GitHub Desktop.
Vermifugos BMS
// ==UserScript==
// @name Vermifugo BMS (albertoos360)
// @description Excludes Brazillian Modding Studio posts by the specified user.
// @include *://brmodstudio.forumeiros.com/*
// @require https://gist.githubusercontent.com/thelink2012/65db658df10a4d94da17/raw/vermifugo-bms.js
// @grant none
// @run-at document-end
// @version 1.0.1
// ==/UserScript==
exterminateVerme("albertoos360");
// ==UserScript==
// @name Vermifugo BMS (Hue no tópico de Ciências)
// @description Excludes Brazillian Modding Studio posts by the specified user.
// @include *://brmodstudio.forumeiros.com/*-ciencia-e-tal
// @require https://gist.githubusercontent.com/thelink2012/65db658df10a4d94da17/raw/vermifugo-bms.js
// @grant none
// @run-at document-end
// @version 1.0.1
// ==/UserScript==
exterminateVerme("Hue");
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
// Include this JS from a userscript to use it.
/**
* Eliminates all posts and quotes by a specified user in the BMS forum.
* @param vermename Exterminates the posts from this username.
*/
function exterminateVerme(vermename)
{
var $ = window.jQuery;
var postWriterRegex = /(.*) escreveu:/g;
/**
* Checks if the specified username is a verme
* @param username The username to be checked.
*/
var isVerme = function(username)
{
return username === vermename;
};
/**
* Hides all the quotes related to the verme from the specified post
* @param postbody The jQuery or DOM element of the post which has the '.postbody' class.
*/
var hideQuotes = function(postbody)
{
var postentry = $(".post-entry:first", postbody);
$("blockquote > div", postentry).each(function() { // (go straight to div so we can hide/replace only the text not the blockquote itself)
var awrote = $("cite:first", this).text().trim();
var match = postWriterRegex.exec(awrote);
if(match != null)
{
if(isVerme(match[1]))
$(this).html("<cite>"+awrote+"</cite>"); // replace the html of the citation with just the cite part
}
});
};
/**
* Matches each post in the forums and post-processes it
*/
$("div#main-content:first").children(".borderwrap:first").children(".post").each(function()
{
var postbody = $(".post-container > .postbody", this);
var author = $(".postbody-head > .author > a", postbody).text().trim();
if(isVerme(author))
$(this).hide(); // Hides verme's post
else
hideQuotes(postbody); // Hides possible verme's quotes in this post
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment