Clip To WorkFlowy Code

Bookmarklet Version 2.5

javascript: (function C2W2_5() {
  function eOPML(str) {
    return str
      .replace(/&/g, '&')
      .replace(/</g, '&lt;')
      .replace(/>/g, '&gt;')
      .replace(/"/g, '"')
      .replace(/(\n)/g, '
');
  };
  function copy2(str) {
    var t = document.createElement('textarea');
    t.value = str;
    document.body.appendChild(t);
    t.select();
    document.execCommand('copy');
    document.body.removeChild(t);
  }
  var isWF = location.href.indexOf('https://workflowy.com/#') === 0;
  if (isWF && item_select.getSelectedItems().length > 0) {
    item_select.clearItemSelection();
  }
  var bullet = isWF ? '<i>See: "' + eOPML(selectOnActivePage(".selected").getName()[0].textContent) + '"</i>' : eOPML(document.title);
  var selected = eOPML(window.getSelection().toString());
  var link = eOPML(location.href);
  var note = selected ? '..' + link + '

' + selected : link;
  copy2('<opml><body><outline text="' + bullet + '" _note="' + note + '" /></body></opml>');
  if (isWF) {
    showMessage('WorkFlowy link is ready to paste.');
    setTimeout(function () {
      hideMessage();
    }, 1500);
  }
})();
Advertisements