diff --git a/workflowy.user.js b/workflowy.user.js new file mode 100644 index 0000000..8889cc3 --- /dev/null +++ b/workflowy.user.js @@ -0,0 +1,43 @@ + +// ==UserScript== +// @name schtobia's combined scripts for workflowy +// @namespace https://www.schtobia.de/ +// @version 0.1 +// @description Combined (i.e., stolen) scripts from all over the interwebz +// @author Tobias Schmidl and others +// @match https://workflowy.com/* +// @grant none +// ==/UserScript== +/* jshint -W097 */ +'use strict'; + + +// you can just use markdown images like +// ![what](http://i.imgur.com/R72rW81.jpg) +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]); + + // NOTE sure why this isn't working + // if ($(this)[0] != document.activeElement) { return; } + + + $(this).after('
' + img[1] + '
') + } +} + +function parseImg() { + $("div.notes div.content").live("click keyup", do_parseImg); + $("div.notes div.content").each(do_parseImg); +}; + +$(window).bind("load hashchange", parseImg);