Skip to content

Instantly share code, notes, and snippets.

@float-mode
Forked from drosenstark/workflowy-with-image.js
Last active January 22, 2016 00:16
Show Gist options
  • Save float-mode/a74817f665a531bb788f to your computer and use it in GitHub Desktop.
Save float-mode/a74817f665a531bb788f to your computer and use it in GitHub Desktop.
workflowy-with-image.js
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://workflowy.com/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
function do_parseImg() {
$(this).nextAll(".content-img").remove();
var lines = $(this).text().split("\n");
var img_re = /^\!\[.*\]\((.+)\)$/;
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim();
var img = line.match(img_re);
if (img === null) {
continue;
}
console.log(i, img[1]);
$(this).after('<div class="content-img"><img src="' + img[1] + '"/></div>')
}
}
function parseImg() {
$("div.notes div.content").live("click keyup", do_parseImg);
$("div.notes div.content").each(do_parseImg);
$("#expandButton").live("click", function() {
$("div.notes div.content").each(do_parseImg);
});
};
$(window).bind("load hashchange", parseImg);
//Got style? Might as well..
$('<style>').text([
'div.notes div.content { height: auto !important; overflow: visible !important; display: block !important; }',
'div.content-img img { max-width: 100%; }'
].join('')).appendTo('head');
@float-mode
Copy link
Author

Added the styles for it here as well..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment