2018-03-09 15:50:19 +01:00
|
|
|
|
|
|
|
// ==UserScript==
|
|
|
|
// @name schtobia's combined scripts for workflowy
|
|
|
|
// @namespace https://www.schtobia.de/
|
2018-03-09 15:52:26 +01:00
|
|
|
// @version 0.1.1
|
2018-03-09 15:50:19 +01:00
|
|
|
// @description Combined (i.e., stolen) scripts from all over the interwebz
|
|
|
|
// @author Tobias Schmidl and others
|
|
|
|
// @match https://workflowy.com/*
|
|
|
|
// @grant none
|
2018-03-09 15:51:52 +01:00
|
|
|
// @downloadURL https://github.com/schtobia/greasemonkey/raw/master/workflowy.user.js
|
|
|
|
// @updateURL https://github.com/schtobia/greasemonkey/raw/master/workflowy.user.js
|
2018-03-09 15:50:19 +01:00
|
|
|
// ==/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('<div class="content-img" style="text-align: left"><img src="' + img[2] + '" alt="' + img[1] + '" title="' + img[1] + '" style="max-width: 85%"/></div>')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function parseImg() {
|
|
|
|
$("div.notes div.content").live("click keyup", do_parseImg);
|
|
|
|
$("div.notes div.content").each(do_parseImg);
|
|
|
|
};
|
|
|
|
|
|
|
|
$(window).bind("load hashchange", parseImg);
|