Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying bookmarklet #48

Open
AtomicNess123 opened this issue Jan 7, 2021 · 1 comment
Open

Modifying bookmarklet #48

AtomicNess123 opened this issue Jan 7, 2021 · 1 comment

Comments

@AtomicNess123
Copy link

How could I modify the below code so that I don't get the PROPERTIES attributes?
I'm aiming at getting the best of the formatting but without certain extras that I don't need.
I suppose that it is to do with modifying the above bookmarklet but I tried several times unsuccessfully.
Thanks for any help provided!

javascript:location.href = 'org-protocol://capture-html?template=w&url=' + encodeURIComponent(location.href) + '&title=' + encodeURIComponent(document.title || "[untitled page]") + '&body=' + encodeURIComponent(function () {var html = ""; if (typeof document.getSelection != "undefined") {var sel = document.getSelection(); if (sel.rangeCount) {var container = document.createElement("div"); for (var i = 0, len = sel.rangeCount; i < len; ++i) {container.appendChild(sel.getRangeAt(i).cloneContents());} html = container.innerHTML;}} else if (typeof document.selection != "undefined") {if (document.selection.type == "Text") {html = document.selection.createRange().htmlText;}} var relToAbs = function (href) {var a = document.createElement("a"); a.href = href; var abs = a.protocol + "//" + a.host + a.pathname + a.search + a.hash; a.remove(); return abs;}; var elementTypes = [['a', 'href'], ['img', 'src']]; var div = document.createElement('div'); div.innerHTML = html; elementTypes.map(function(elementType) {var elements = div.getElementsByTagName(elementType[0]); for (var i = 0; i < elements.length; i++) {elements[i].setAttribute(elementType[1], relToAbs(elements[i].getAttribute(elementType[1])));}}); return div.innerHTML;}());

@AtomicNess123
Copy link
Author

Also, for instance,

("p" "Protocol" item (file+headline "~/protocol.org" "inbox")
        "- %:initial <%:annotation>")

Using org-protocol-capture gives me a new line between the text selection and the link (and I would like no new line, just a space). This I can achieve with the basic org-protocol bookmarklet, but then I would be missing the enhancements of your package! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant