Skip to content

Instantly share code, notes, and snippets.

@mtandre
mtandre / bookmarlet.js
Created February 20, 2015 21:40
Clickability Bookmarklet: toggle production/stage environment
//Clickability Bookmarklet: toggle production/stage environment
javascript:(function(){var a=window.location.host;window.location.host=-1<a.indexOf("stage.")||-1<a.indexOf("dev.")?a.replace(/^(stage|dev)\./,""):"stage."+a;})();
@mtandre
mtandre / bookmarklet.js
Last active August 29, 2015 14:15
Clickability Bookmarklet: cache buster - get fresh copy of page
//Clickability Bookmarklet: cache buster - get fresh copy of page
javascript:(function(){for(var a=window.location.search.substring(1),b="",c=0;8>c;c++)var d=Math.floor(26*Math.random()),b=b+"ABCDEFGHIJKLMnopqrstuvwxyz".substring(d,d+1);a=0<a.length?-1<a.indexOf("&c=")?a.replace(/&c=\w{7,9}/,"&c="+b):a+"&c="+b:"?c="+b;window.location.search=a;})();
@mtandre
mtandre / bookmarklet.js
Created February 20, 2015 21:41
Facebook Debug: clear Facebook's webpage cache (max 50 per url)
//Facebook Debug: clear Facebook's webpage cache (max 50 per url)
javascript:(function(){ var encodedUrl=encodeURIComponent(window.location.href);function createXMLHTTPObject(){var XMLHttpFactories=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];var xmlhttp=false;for(var i=0;i<XMLHttpFactories.length;i++){try{xmlhttp=XMLHttpFactories[i]()}catch(e){continue}break}return xmlhttp} function sendRequest(articleUrl){var req=createXMLHTTPObject();if(!req||!articleUrl)return null;req.open("POST","http://graph.facebook.com/",true);req.setRequestHeader("Content-type","application/x-www-form-urlencoded");req.onreadystatechange=function(){if(req.status==200&&req.readyState==4){console.log(req.responseText);var obj=JSON.parse(req.responseText);alert("Article refreshed.\nTitle: "+obj.title+"\nurl: "+obj.url)}};req.send("id="+encodedUrl+"&scrape=true")}sendRequest(en
@mtandre
mtandre / tooltip.html
Created June 17, 2015 13:53
basic tooltip
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>tooltip</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.button {
border: 1px solid gray;
@mtandre
mtandre / bookmarklet.js
Last active August 2, 2016 19:28
CMS Bookmarklet: Open current page in CMS search
javascript:(function() {
var siteCodes = {"www.jsonline.com": "PMJS"};
var siteCode = siteCodes[window.location.host];
if (siteCode === "PMJS") {
var id = parseInt(window.location.pathname.split("/").slice(-2)[0],10);
if (id > 0) {
var searchUrl = 'https://presto-wigroup.gannettdigital.com/#/?k=' + id + '&st=' + siteCode + '&pg=1&pgs=25';
window.open(searchUrl, '_blank');
}
} else {
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>text ticker / scroller</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.text-ticker {
-webkit-animation: textscroller 30s linear infinite;
@mtandre
mtandre / navigation-helper.js
Last active February 27, 2019 19:23
"Amazon inspired" hover navigation menu with trajectory projection
(function () {
var inTriangle = false, link = false,
navigation = document.querySelector('.navigation--sections'),
allNavItems = document.querySelectorAll('.navigation--item'),
x0, y0, x1, x2, x3, y1, y2, y3, hoverDelay;
navigation.addEventListener('mouseenter', onmouseenter);
navigation.addEventListener('mouseleave', onmouseleave);
function isInsideTriangle() {
@mtandre
mtandre / bookmarklet.js
Created December 28, 2015 21:37
Clickability Bookmarklet: Toggle Mobile
javascript:(function(){
var url = window.location.href,
newUrl = "";
if (url.indexOf("jsonline.com") > -1) {
if (url.indexOf("www.jsonline.com") > -1) {
newUrl = url.replace(/www\./i,"m.");
} else {
newUrl = document.querySelector("link[rel='canonical']").href + window.location.search;
}
} else {
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
</head>
<body>
</body>
</html>

Keybase proof

I hereby claim:

  • I am mtandre on github.
  • I am mtandre (https://keybase.io/mtandre) on keybase.
  • I have a public key ASD75OV6nGdRynPx6besxJlbvH2qdS2iuZ6gkD9m2Q-nhQo

To claim this, I am signing this object: