Skip to content

Instantly share code, notes, and snippets.

View theftprevention's full-sized avatar

Jacob McCollum theftprevention

View GitHub Profile
@theftprevention
theftprevention / select-facebook-ads.js
Created February 7, 2019 04:15
Hides all stories in the Facebook news feed except for sponsored advertisements. This is the antithesis to "remove-facebook-ads.js", as requested by /u/datlean.
// ==UserScript==
// @name Select Facebook Ads
// @version 1.0
// @description Hides all stories in the Facebook news feed except for sponsored advertisements.
// @author theftprevention
// @match https://www.facebook.com/
// @grant none
// ==/UserScript==
(function() {
@theftprevention
theftprevention / remove-facebook-ads.js
Last active February 7, 2019 00:33
Periodically removes sponsored content from the Facebook news feed.
// ==UserScript==
// @name Remove Facebook Ads
// @version 1.0
// @description Removes sponsored content from the Facebook news feed.
// @author theftprevention
// @match https://www.facebook.com/
// @grant none
// ==/UserScript==
(function() {
@theftprevention
theftprevention / charCount.js
Last active June 19, 2016 00:45
Defines the "charCount" method, which returns the number of characters in a string. Assumes that the browser / environment supports the ECMAScript 6 String.prototype.codePointAt() method (IE 11+).
(function (window) {
'use strict';
var charCodeAt, codePointAt;
if (!window.charCount) {
charCodeAt = String.prototype.charCodeAt;
codePointAt = String.prototype.codePointAt;
@theftprevention
theftprevention / jquery-scrolllock.js
Last active July 3, 2020 06:30
A small jQuery extension that disables the propagation of scroll events from the first element in the set of matched elements. Original function by Troy Alford of Stack Overflow.$("#object").scrollLock() enables the lock, and .scrollRelease() disables it.
$.fn.scrollLock=function(){return $(this).on("DOMMouseScroll mousewheel",function(h){var g=$(this),f=this.scrollTop,d=this.scrollHeight,b=g.height(),i=h.originalEvent.wheelDelta,a=i>0,c=function(){h.stopPropagation();h.preventDefault();h.returnValue=false;return false};if(!a&&-i>d-b-f){g.scrollTop(d);return c()}else{if(a&&i>f){g.scrollTop(0);return c()}}})};$.fn.scrollRelease=function(){return $(this).off("DOMMouseScroll mousewheel")};