IPhone Safari Bookmarklet to paste clipboard into Drafts - iphone

This may be really simple, since I can't use window.getSelection on iPhone Safari, I was wondering if I could put the selection in the clipboard and use a bookmarklet to send it to Drafts (among with location.href)
The first part of the equation is quite simple:
javascript:window.location='drafts://x-callback-url/create?text='+encodeURIComponent(location.href+'%5Cn%5Cn')
As I'm a rookie, I interpreter this "create a new document in Drafts and append the current window link to the top and press return twice", now I just need to add the contents from the clipboard into this.
If I simply use the Drafts short [[clipboard]]to add the clipboard, it won't work. So I'm suspicious that I'll need a Java solution. Ideas?

unfortunately, it seems like, according to the state of things as they are right now, this is impossible. I'm better off with the clipboard in the iPhone, it seems. Thank you for checking out.
The command I was looking for is available in the iPad, you can reach it through this:
javascript:window.location='drafts://x-callback-url/create?text='+encodeURIComponent(location.href+'%5Cn%5Cn')+encodeURIComponent(window.getSelection())
According to the article by Federico Viticci, this encodeURIComponent(window.getSelection()) being the snippet that grabs the actual selection.
This happens because when you open the bookmarks tab in the iPhone, it deselects your selection and the snippet becomes useless. In the iPad, you must keep the Always Show Bookmarks option on.

The latest version of iCab Mobile has a variety of gestures, a draw-gesture feature, and a bookmarklet list called "Modules" that is (unofficially) customizable. On both the iPad and the iPhone, gesture recognition can execute JavaScript or launch apps by URL scheme without affecting your selection. It also happens to support x-callback-URL as well. :)

Related

How to attach images to github issues without dragndrop?

Is there a way to attach images to github issues without drag'n'drop, copy-pasting images or jumping through various hoops - just by using a file picker?
I find drag'n'drop very inconvenient, and copy-paste does not work in Firefox (on top of being rather inconvenient as well).
Github help page only mentions drag'n'drop, or copy-paste for Chrome.
The question here on adding images lists additional methods like creating a custom repository or wiki.
All of that is enough of a pain in the ass for me to ask a question here, hoping for a hidden way to use normal file picker.
There is a file picker. Simply click on the Attach files by dragging & dropping, selecting them, or pasting from the clipboard field.
Yes there is, its very simple, but not intuitive.
Consider this example where you want to comment:
Just click the highligted section with the text "Attach files by dragging and dropping, selecting them, ...".
Then a file dialog will open up:

How can I edit focused text field? (Swift, macOS)

I'm trying to make little utility for macOS(not iOS) using by Swift(newbie).
I guess this utility would be
command line tool triggered by other apps or
Menu bar application.
I implemented features that I've wanted,
but I have no idea how to edit focused text field.
e.g. Get text from a text editor(atom, sublime, ... when this app triggered.) and make some changes on that text and paste back to the text editor.
I want to make this app works on system-wide,
I want to know how to implement things below
Get text from currently active/focused text field.
Delete text on currently active/focused text field.
Paste text to currently active/focused text field.
(text means just one word or line before the cursor)
I'm trying this on command line tool and keyboard event(CGEvent) now which seems no good idea.
Please help!
I think you need to implement a system service, like described in the docs here.
The relevant parts (although you need to read it all) are here in the section "Sending Data to the Service" or "Receiving Data from the Service" (it's done using the pasteboard).
As an alternate solution (maybe better) you should consider packaging your app as a share app extension (see here)
Take a look at the macOS accessibility features in the ApplicationServices framework. Specifically, the classes with an "AX" prefix (these are the accessibility ones). It's not the prettiest thing to work with (especially in Swift) but you can achieve what you want with it.

How can one suppress automatic refresh of open browser windows on the iPhone, iPad, etc. when switching back into them?

The question is: How can one suppress the annoying auto-refresh of open web browsers in Safari, etc., when the user of an iPhone or iPad switches back into it after switching out of it? There appears to be no setting that can do this on these devices.
Today I inadvertently discovered a way to stop this annoying behavior, even though it does not qualify as a real fix, it is a method of suppressing the behavior by taking a simple action every time prior to switching out from Safari or another browser. Not ideal, but it does give you control (finally) of the browser such that the behavior is suppressed. The link to the answer is here:
https://discussions.apple.com/message/25254749#25254749
If you don't feel like surfing there, here's the trick:
In Safari or another browser app, touch and hold on a piece of text (a single word or letter is fine), then lift your finger off the screen. The word or letter will be selected and the familiar little pop-up that says "Copy | Define" appears. Touch "Define" and the screen that shows the word's definition or says it couldn't find a definition pops up. Now, do not touch anything else; not "Done", "Search the Web", or anything else. Now press the Home button (i.e., the one on the bottom portion of the front face panel of the iPhone with the square in it). You will be switched back to the springboard with all your app icons and from there can do anything else you want. Then, touch the browser icon for the browser you were in and you'll switch back into it. The definition screen covering the browser window will still be there. Touch "Done", and the screen drops away. Blessedly, the open browser window(s) will not reload.
Update:
In Mercury, the trick hasn't failed me so far. However in Safari, sometimes it fails to work when many apps are backgrounded and many browser windows are open. Possibly because Safari is bundled with iOS and written by devs in the same company, the Springboard may have more hooks into it and been programmed to have more discretionary power over its behavior. And a blocking process initiated by Springboard is cancellable by Springboard; if not, then it'd hardly be consistently useful as an OS. But I have noticed that by placing Safari in its select-browser state (touch the lower-right one-square-on-top-of-the-other icon in Safari that causes the browser windows to stack tilting forward, pseudo-3D style) and then switching out to the Springboard and doing whatever, etc., then back into Safari, that also seems to work, even with a lot of browser windows and apps open. But as we all know, some web pages have Javascript that force an auto-refresh based on last date-time of retrieval which they store in their DOM, usually in a hidden field or some other place. So that can't be helped when a browser window becomes active. However lacking that, the window doesn't refresh. So in terms of getting consistently positive results when trying to suppress auto-reload when using Safari, I recommend this approach more often than the more general one I described first.

is there any eclipse plugin available for writing a memo on any line of code?

Doe anybody know of an eclipse plugin, which can be used to insert short text (in the form of memo) to remember what that line of code does or a block of code does to help me understand the existing code better and i can also refer it back later on.
Just like "Task" can be added on a line of code, although i can use "tasks" for this purpose, but that is not very convenient and intuitive.
If you want to add a short text to "remember what that line of code does or a block of code does to help me understand the existing code better", use comments. That's what they're for, and practically every formal language in the world has them.
If you want the ability to quickly jump to an arbitrary point in the code, using bookmarks is a convenient option - right click the bar immediately left of the text and choose to add a bookmark. You can then easily jump between bookmarks with the "bookmark view", which you can enable from the Window -> Show View menu.
The closest thing I can think of is bookmark support. There is native bookmark support in Eclipse and also several other vendors supply more function.
I'm assuming that there's a very good reason that you don't want to or can't modify the code.

Way to use a native editor for textarea (or JS-powered WYSIWYG editor)?

I'm looking for a way to use my favorite "native" editor, Sublime Text 2, to fill textareas and/or WYSIWYG-editors like TinyMCE.
I'd like to have some kind of daemon, service or browser extension that waits for, say, a focus event on a textarea and opens a new Sublime Text 2 window for me to type in. Everytime I save (could be to a file in a temporary directory for all I care), the background daemon/service/extension/… updates the contents of the web form field.
So much for my ideal scenario. Is there any way you know of to make this possible (FYI, I'm working under OS X Lion)?
I don't know what browser you're using, but there's an extension for Firefox called "It's all text" where you can:
Right click on a textarea, select "It's All Text!" and edit the text in the editor of your choice.
You can also make a shortcut instead of rightclicking.
[EDIT] And for Google Chrome now there is: https://github.com/Cacodaimon/GhostTextForSublimeText
P.S. In an ideal world all textareas should be small ST2 windows...
Sure, this is possible.
You'll need to write a browser extension for it.
Look for a snippet saving addon on whichever browser you use, go through the source code, figure out how it works, then make one to fit your use-case.
In the meantime, repeat: Ctrl+C, Alt-Tab, Ctrl-V!