Last active
November 10, 2016 16:51
-
-
Save doyousketch2/ec652a639ea31399510964af29fba11f to your computer and use it in GitHub Desktop.
Dims facebook's mobile page, blocks ads, filters posts with keywords for you, and makes images click-to-fullsize.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name m.fb.Dim | |
// @namespace Sketch2 | |
// @description mobile.facebook.Dimmer | |
// @include https://m.facebook.* | |
// @exclude https://m.facebook.com/friends/* | |
// @version 1.8 | |
// @grant GM_info | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// @grant GM_xmlhttpRequest | |
// @grant GM_registerMenuCommand | |
// @updateURL https://git.io/vX0QU | |
// @require https://code.jquery.com/jquery-3.1.1.slim.min.js | |
// @license GNU GPLv3 - https://www.gnu.org/licenses/gpl-3.0.html | |
// ==/UserScript== | |
//------------------- | |
// keywords to block. | |
// lowercase or uppercase; no preference. Script will check both for you. | |
var BLOCKLIST = ['vote', 'Trump', 'Hillary', 'Clinton', | |
'elect', 'republican', 'democrat']; | |
//--------------------------------------- | |
// surround your keywords with 'quotes' | |
// separated by a comma, | |
// be sure the entire list is surrounded with [brackets] | |
// then finish with a semicolon; | |
//--------------------------------------- | |
// this next list is keywords to ignore. | |
// I discovered the word 'electronics' contains the word 'elect' | |
// and so, was unexpectedly being highlighted. | |
// put words here that you don't want to be accidentially tagged. | |
var WHITELIST = ['electron']; | |
//----------------------------- | |
// Standard websafe hex Colors | |
// #RRGGBB (or) #RGB | |
var OuterBackground, OB = '#013' | |
var InnerBackground, IB = '#347' | |
var NewsFeed, NF = '#111' | |
var NewsItem, NI = '#446' | |
var Fields = '#335' | |
var Highlight, HL = '#500' | |
var Font1 = '#975' | |
var Font2 = '#570' | |
var Font3 = '#000' | |
//---------------------------------- | |
//font size that the blocklist uses. | |
var FontSize = '10px' | |
//================================================================= | |
// Don't edit below this line, unless you know jQuery / Javascript | |
//dim outer background | |
$('body') .css('background', OB); | |
//dim inner background | |
$('div#root') .css('background', IB); | |
$('div#root div') .css('background', IB); | |
$('div#root div div') .css('background', IB); | |
$('div#root div div div') .css('background', "linear-gradient(to right, " + NI + ", " + Fields + ")") .find('div') .css('background', NI); | |
//dim news stream | |
$('div#m_newsfeed_stream div') .css('background', NF); | |
$('div#m_newsfeed_stream div div') .css('background', NI); | |
//input | |
$('div#mbasic_inline_feed_composer') .css('background', IB); | |
$('div#mbasic_inline_feed_composer') .parent() .css('background', IB); | |
//buttons | |
$('div#mbasic_inline_feed_composer div') .css('background', OB); | |
//fade background | |
$('div#mbasic_inline_feed_composer') .children('form') .children('div') .css('background', "linear-gradient(to right, " + OB + ", " + IB + ")"); | |
//text | |
$('a') .css('color', Font1); | |
$('h3') .css('color', Font2); | |
$('h3') .next('div') .css('color', Font3); | |
$('p') .css('background', NewsItem); | |
$('a:contains(See All Notifications)') .css('background', "linear-gradient(to right," + OB + ", " + IB + ")"); | |
$('a:contains(Show more)') .css('font-size','22px'); | |
//hide random people | |
$('h3:contains(People You May Know)') .parent() .hide(); | |
$('a:contains(See All Friend Requests)') .parent().parent().parent().parent() .hide(); | |
//hide birthdays | |
$('a:contains(birthday)') .parent().parent().parent().parent() .hide(); | |
//hide SMS notice | |
$('span:contains(Receive your notifications via SMS)') .parent() .hide(); | |
//clear background of video buttons | |
$('span:contains(Play Video)') .parent() .css('background',''); | |
//clear background of links | |
$('a') .children() .css('background', ''); | |
//wider is better | |
$('div#viewport') .css('max-width','70%'); | |
//languages | |
$('div#viewport') .children('div:last') .not('div#objects_container') .children('div:first') .remove(); | |
//next page- bigger text | |
$('div#root') .children('div:first') .not('div#m_story_permalink_view') .children('div:last') .css('font-size','20px'); | |
$('a:contains(Next)') .css('font-size','26px') | |
//bigger pic + no tag or report buttons to get in the way | |
$('a:contains(View Full Size)') .css('font-size','18px') .siblings() .remove(); | |
//make images clickable, to view full size | |
$('a:contains(View Full Size)') .each(function(){ | |
$('div#root div:first div:first div:first div:first div:first img') .wrap('<a></a>') .parent() .attr('href', $(this) .attr('href')); | |
}); | |
//add a text container | |
$('a:contains(View Full Size)') .after('<span class="imageText"></span>'); | |
//add image tags to the text container | |
$('span.imageText') .html($('a:contains(View Full Size)') .parentsUntil('div#root') .find('img') .attr('alt')) | |
.css('padding', '0px 40px') .css('font-size','12px'); | |
//see more photos | |
$('div#m_more_item') .css('font-size','22px'); | |
//hide ads | |
$('span:contains(Sponsored)') .parent().parent().parent() .hide(); | |
//fields | |
$('div#root a') .children('div') .attr('class','') .css('background', "linear-gradient(to right, " + Fields + ", " + NI + ")"); | |
//block keywords | |
for (var i = 0; i < BLOCKLIST .length; i++) { | |
//all lowercase letters to begin with | |
var Lower = BLOCKLIST[i] .toLowerCase(); | |
var LoW = WHITELIST[i] .toLowerCase(); | |
//convert first letter to uppercase | |
var Upper = Lower .substr(0,1) .toUpperCase() + Lower .substr(1); | |
var UpW = LoW .substr(0,1) .toUpperCase() + LoW .substr(1); | |
//try both lower, and uppercase, permutations. | |
$('h3:contains(' + Lower + ')') .add('span:contains(' + Lower + ')') //lowercase versions | |
.add('h3:contains(' + Upper + ')') .add('span:contains(' + Upper + ')') //uppercase | |
.not(':contains(' + LoW + ')') .not(':contains(' + UpW + ')') //excluding words from whitelist | |
.css('font-size', FontSize) .parent().parent() //shrink text a bit, then select outer container | |
.css('background', "linear-gradient(to right, " + HL + ", " + NI + ")"); //so we can highlight it. | |
//you could .remove() the whole block here, if you really felt like it. | |
}; | |
$('div') .css('font-size',''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Firefox users need
Chrome users need
Once you have one of those, press the 'Raw' button on the top-right corner of the script.
(normally that would show you the raw text, but GreaseMonkey and
TamperMonkey recognize the text as a script, so they ask if you want to install it.)