Create workflowy.user.js
This commit is contained in:
parent
5312dc68f6
commit
a43994efa4
1 changed files with 43 additions and 0 deletions
43
workflowy.user.js
Normal file
43
workflowy.user.js
Normal file
|
@ -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('<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);
|
Loading…
Reference in a new issue