Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit c93e3255dea6f2238cc8c467389905fb4c5e9d57 @marcia committed Sep 23, 2011
Showing with 74 additions and 0 deletions.
  1. +7 −0 README.md
  2. +22 −0 background.html
  3. +21 −0 contentscript.js
  4. BIN icon.png
  5. +4 −0 jquery.js
  6. +20 −0 manifest.json
@@ -0,0 +1,7 @@
+* Tools => Extensions
+* Show developer mode
+* Load unpacked extension
+* Point to sesame
+* Visit something like https://github.com/Khan/khan-exercises/issues/3082
+* Click on the page action leaf icon to open the referenced problem locally
+* BONUS: Type "o" to do the same thing
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script>
+ function showPageAction( request, sender, sendResponse ) {
+ // Show the page action leaf icon
+ chrome.pageAction.show( sender.tab.id );
+ // Return nothing to let the connection be cleaned up
+ sendResponse({});
+ };
+
+
+ // Listen for the content script to send a message
+ chrome.extension.onRequest.addListener( showPageAction );
+
+ // Send a request to contentscript, which will open the new tab
+ chrome.pageAction.onClicked.addListener( function( tab ) {
+ chrome.tabs.sendRequest( tab.id, {} );
+ });
+</script>
+</head>
+</html>
@@ -0,0 +1,21 @@
+// Depending on how your environment is set up,
+// you may need to change the base variable
+function openProblemInNewTab( request, sender, sendResponse ) {
+ var exercise = jQuery( ".content-body:first" ).text().match( /.*html.*/ );
+ var base = "http://localhost/khan-exercises/exercises/";
+ window.open( base + exercise.pop(), "_blank" );
+}
+
+// Listen for the request to open the problem in a new tab,
+// which comes from the background page
+chrome.extension.onRequest.addListener( openProblemInNewTab );
+
+chrome.extension.sendRequest({}, function( response ) {});
+
+jQuery( function() {
+ jQuery( document ).keypress( function( event ) {
+ if ( event.which === 111 ) {
+ openProblemInNewTab();
+ }
+ });
+})
BIN icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,20 @@
+{
+ "name": "sesame",
+ "version": "1.0",
+ "description": "Click the leaf page action open the referenced problem locally",
+ "background_page": "background.html",
+ "page_action" :
+ {
+ "default_icon" : "icon.png"
+ },
+ "permissions" : [
+ "tabs"
+ ],
+ "content_scripts": [
+ {
+ "matches": ["https://github.com/Khan/khan-exercises/issues/*"],
+ "js": ["jquery.js", "contentscript.js"],
+ "run_at": "document_idle"
+ }
+ ]
+}

0 comments on commit c93e325

Please sign in to comment.