-
-
Save davist11/369fe266176d45b488fd to your computer and use it in GitHub Desktop.
Chrome Extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data; | |
chrome.extension.onMessage.addListener(function(details) { | |
data = details; | |
}); | |
chrome.browserAction.onClicked.addListener(function(tab) { | |
chrome.tabs.executeScript(null, { | |
file: 'contentscript.js' | |
}); | |
chrome.windows.create({ | |
url: 'http://my_url_to_a_publish_form', | |
height: 800, | |
width: 800, | |
type: 'popup' | |
}, function() { | |
chrome.windows.getCurrent(function(window) { | |
chrome.tabs.getSelected(window.id, function (response){ | |
chrome.tabs.executeScript(null, { | |
file: 'insertdata.js' | |
}, function() { | |
chrome.tabs.sendMessage(response.id, data); | |
}); | |
}); | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: INCLUDE jQUERY SOURCE HERE | |
var title = $('meta[property="og:title"]').attr('content'); | |
var source = window.location.href; | |
var img = $('meta[property="og:image"]').attr('content'); | |
var content = window.getSelection().toString(); | |
if(title === '') { | |
title = $('title').text(); | |
} | |
var details = { | |
title: title, | |
source: source, | |
img: img, | |
content: content | |
}; | |
chrome.extension.sendMessage(details); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: INCLUDE jQUERY SOURCE HERE | |
chrome.extension.onMessage.addListener(function(details) { | |
//TODO: how do i fire this stuff after jquery and the rest of the window is loaded | |
$('#publish-title').val(details.title).trigger('keyup'); | |
$('input[name="page[yaml][source]"]').val(details.source); | |
$('#publish-content').val(details.content); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Add Recipe", | |
"version": "1.1", | |
"manifest_version": 2, | |
"description": "Add a recipe from a URL", | |
"background": { | |
"scripts": ["background.js"] | |
}, | |
"browser_action": { | |
"default_icon": "icon.png" | |
}, | |
"permissions": [ | |
"tabs", "http://*/", "https://*/" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment