Skip to content

Instantly share code, notes, and snippets.

//Gruber wrote this regex for matching URLs, but it took a small amount of massage to use it in JavaScript. So here.
//Sauce: http://daringfireball.net/2010/07/improved_regex_for_matching_urls
var p = /\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i;
p.exec('party fun www.twitter.com yay') //winning.
@BrockA
BrockA / waitForKeyElements.js
Created May 7, 2012 04:21
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
@TaraRed
TaraRed / autoreviewcomments.user.js
Created July 12, 2012 18:56 — forked from Benjol/autoreviewcomments.user.js
PFC that works for new /review
// ==UserScript==
// @name AutoReviewComments
// @namespace benjol
// @version 1.2.3
// @description Add pro-forma comments dialog for reviewing (pre-flag)
// @include http://*stackoverflow.com/questions*
// @include http://*stackoverflow.com/review*
// @include http://*stackoverflow.com/admin/dashboard*
// @include http://*stackoverflow.com/tools*
// @include http://*serverfault.com/questions*
@TaraRed
TaraRed / ReviewKeyboard.user.js
Created July 13, 2012 14:50
Allows you to use "1", "2", "3" and "4" to press the review buttons in the review tools.
// ==UserScript==
// @author Tom Wijsman
// @name Review Keyboard
// @description Allows you to use "1", "2", "3" and "4" to press the review buttons in the review tools.
// @include http://*superuser.com/review-beta/*
// ==/UserScript==
function EmbedCodeOnPage(javascript_code) {
var code_element = document.createElement('script');
code_element.type = 'text/javascript';
@iglvzx
iglvzx / getIP.md
Last active January 2, 2016 12:28
@turbobabr
turbobabr / _.isDefined.js
Last active November 22, 2016 03:23
Underscore.js isDefined mixin
// Underscore.js isDefined mixin
// Returns true if value is defined.
_.mixin({
isDefined: function(reference) {
return !_.isUndefined(reference);
}
});
/* Example:
var obj = {
@fuzzykiller
fuzzykiller / Greasemonkey.js
Last active February 16, 2020 11:20 — forked from azu/Greasemonkey.js
Greasemonkey API stubs with JSDoc, for WebStorm etc
/**
* Created by azu.
* Date: 10/11/28
* Updated by fuzzykiller (2015/08/28)
* License: MIT License
*/
/**
* An object that exposes various information about Greasemonkey and the running User Script.
*/