Skip to content

Instantly share code, notes, and snippets.

@blork
Created September 5, 2014 19:58
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blork/e2780fd7e2a1a95f57d3 to your computer and use it in GitHub Desktop.
Save blork/e2780fd7e2a1a95f57d3 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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
Copy link

ylovesy commented Nov 4, 2014

nice code!

@ylovesy
Copy link

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