This file contains hidden or 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
| var ready = function ( fn ) { | |
| if ( typeof fn !== 'function' ) return; | |
| if ( document.readyState === 'interactive' || document.readyState === 'complete' ) { | |
| return fn(); | |
| } | |
| document.addEventListener( 'DOMContentLoaded', fn, false ); | |
| }; | |
| ready(function() { | |
| // add your code here |
This file contains hidden or 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
| // add script (e.g jQuery) to current website via developer console (lives only within the client) | |
| var jq = document.createElement('script'); | |
| jq.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"; | |
| document.getElementsByTagName('head')[0].appendChild(jq); |
This file contains hidden or 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
| /* About: function to handle touch direction in browser | |
| Usage: custom event: custom_handleTouch:'direction' (direction = left, right, up, down) | |
| Example: $(document).on('custom_handleTouch:left', function() { // own code }); | |
| */ | |
| function handleTouchGestures() { | |
| document.addEventListener('touchstart', handleTouchStart, false); | |
| document.addEventListener('touchmove', handleTouchMove, false); | |
| var xDown, yDown = null; |
This file contains hidden or 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
| /* About: function to detect if and how much of a certain element is in viewport | |
| Usage: function is added to the jQuery object and can be called on any jQuery selector | |
| Example: $(selector).isInViewport(.5, .5) => true == element is 50% in viewport | |
| @return Boolean | |
| */ | |
| $.fn.isInViewport = function(x, y) { | |
| if(x == null || typeof x == 'undefined') x = 1; |
This file contains hidden or 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
| // Detect scroll direction | |
| (function scrollPosition() { | |
| "use strict" | |
| // get last scroll position | |
| let lastY = window.scrollY; | |
| let running = false; | |
| function getScrollPosition() { |
This file contains hidden or 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 Disable quora blocker | |
| // @namespace Quora | |
| // @version 1 | |
| // @description Disable quora blocker | |
| // @author Me | |
| // @include http*//de.quora.com/* | |
| // @include http*//www.quora.com/* | |
| // @grant none | |
| // ==/UserScript== |
This file contains hidden or 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
| // removes and adds placeholder onfocus/ blur (jQuery) | |
| $('input, textarea').focus(function(){ | |
| $(this).data('placeholder',$(this).attr('placeholder')) | |
| .attr('placeholder',''); | |
| }).blur(function(){ | |
| $(this).attr('placeholder',$(this).data('placeholder')); | |
| }); | |
| // removes and adds placeholder onfocus/ blur (ES6) | |
| document.querySelectorAll('input, textarea').forEach(elem => { |
This file contains hidden or 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
| // Remove duplicates from array | |
| var testArr = ["a", "a", "b", "b", "c"]; | |
| function removeDuplicates(arr) { | |
| return arr.filter(function(elem, index, fullArr) { | |
| return index === fullArr.indexOf(elem); | |
| }); | |
| } | |
| removeDuplicates(testArr); |