Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
iOS Extension Web Page Preprocessor
var MyPreprocessor = function() {};
MyPreprocessor.prototype = {
run: function(arguments) {
// Pass the baseURI of the webpage to the extension.
arguments.completionFunction({"URL": document.URL, "pageSource": document.documentElement.outerHTML, "title": document.title, "selection": window.getSelection().toString()});
}
};
// The JavaScript file must contain a global object named "ExtensionPreprocessingJS".
var ExtensionPreprocessingJS = new MyPreprocessor;
@blork

This comment has been minimized.

Copy link
Owner Author

@blork blork commented Sep 5, 2014

You can access the info from Obj-C using the result dictionary, e.g. results[@"pageSource"].

(see https://gist.github.com/blork/3908619597ab4515941d)

@ylovesy

This comment has been minimized.

Copy link

@ylovesy ylovesy commented Nov 4, 2014

nice code!

@ylovesy

This comment has been minimized.

Copy link

@ylovesy ylovesy commented Nov 4, 2014

Is it a way to get the logo image source?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment