Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update add-on to work with Opera 15. #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# kippt-opera

This is Kippt.com's official Firefox add-on. It's licensed under MIT and we'll accept improvements in pull-requests.
This is Kippt.com's official Opera add-on. It's licensed under MIT and we'll accept improvements in pull-requests.

Originally created by @armen138
Originally created by @armen138.

## Building extension

To build the extension, add the files to .zip and thne change the extension of the file to .oex
* 1. Go to "opera://extensions", click on the "Developer mode".
* 2. Click on "Load unpacked extension..." and then select the "kippt-opera".
* 3. Restart Opera after succesful installing.

NB. The extension will only play nice with pages that were loaded after the extension was activated.
To be sure all works as it should, restart Opera after installing.
NOTE: The extension will only play nice with pages that were loaded after the extension was activated.
24 changes: 13 additions & 11 deletions includes/getinfo.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
opera.isReady(function(){
opera.extension.onmessage = function(event) {
var kippt = {},
titles = document.documentElement.getElementsByTagName("title");
kippt.title = "";
if(titles.length > 0) {
kippt.title = titles[0].innerHTML;
}
kippt.url = window.location.toString();
kippt.notes = window.getSelection().toString();
if(event.data === "getinfo" && kippt.url.indexOf("widget") === -1) {
event.source.postMessage(kippt);
}
var kippt = {
}, titles = document.documentElement.getElementsByTagName("title");
kippt.title = "";
if (titles.length > 0) {
kippt.title = titles[0].innerHTML;
}
kippt.url = window.location.toString();
kippt.notes = window.getSelection().toString();
if (event.data === "getinfo" && kippt.url.indexOf("widget") === -1) {
event.source.postMessage(kippt);
}
};
});
42 changes: 1 addition & 41 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,41 +1 @@
<!doctype html>
<html lang="en">
<head>
<script>
var ext = window.opera.extension,
kippt = {},
tabs = {},
popup = null,
button;
window.addEventListener("load", function(){
ToolbarUIItemProperties = {
title: "Kippt",
icon: "kippt.png",
popup: {
href: "pop.html",
width: 420,
height: 235
}
}
button = opera.contexts.toolbar.createItem(ToolbarUIItemProperties);
opera.contexts.toolbar.addItem(button);
}, false);
ext.onmessage = function(event) {
var tab = ext.tabs.getFocused(),
url = tab ? tab.url : "";
if(event.data === "getme") {
popup = event.source;
if(tab) {
tab.postMessage("getinfo");
} else {
popup.postMessage({url: "", title: ""});
}
} else {
popup.postMessage(event.data);
}
};
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html><html lang="en"><head><script src="oex_shim/operaextensions_background.js"> </script> <script src="inline_script_index_1.js"></script> </head> <body> </body></html>
13 changes: 13 additions & 0 deletions inline_script__1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
opera.isReady(function(){
var url = window["url"] = "", title = window["title"] = "";
window.addEventListener('DOMContentLoaded', function() {
opera.extension.postMessage('getme');
}, false);
opera.extension.onmessage = function(event) {
var iframe = document.getElementById("kippt");
url = event.data.url;
title = event.data.title;
notes = event.data.notes || "";
iframe.src = 'https://kippt.com/extensions/new/?url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title) + '&source=opera&notes=' + encodeURIComponent(notes);
};
});
34 changes: 34 additions & 0 deletions inline_script_index_1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
opera.isReady(function(){
var ext = window["ext"] = window.opera.extension, kippt = window["kippt"] = {
}, tabs = window["tabs"] = {
}, popup = window["popup"] = null, button = window["button"];
window.addEventListener("load", function() {
ToolbarUIItemProperties = {
title: "Kippt",
icon: "kippt.png",
popup: {
href: "pop.html",
width: 420,
height: 235
}
};
button = opera.contexts.toolbar.createItem(ToolbarUIItemProperties);
opera.contexts.toolbar.addItem(button);
}, false);
ext.onmessage = function(event) {
var tab = ext.tabs.getFocused(), url = tab ? tab.url : "";
if (event.data === "getme") {
popup = event.source;
if (tab) {
tab.postMessage("getinfo");
} else {
popup.postMessage({
url: "",
title: ""
});
}
} else {
popup.postMessage(event.data);
}
};
});
15 changes: 15 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Kippt",
"developer": {"name" : "Kippt", "url" : "http://kippt.com"},
"description" : "Kippt's Opera add-on - http://kippt.com",
"manifest_version" : 2,
"version" : "0.1",
"background" : {"page" : "index.html"},
"icons" : {"128": "kippt.png"},
"browser_action" : {},
"content_scripts": [
{"js": ["oex_shim/operaextensions_injectedscript.js", "includes/getinfo.js"], "matches": ["<all_urls>"], "include_globs": ["*"], "exclude_globs": [], "run_at": "document_start", "all_frames" : true}],
"web_accessible_resources" : ["includes/getinfo.js","kippt.png","kippt_big.png","kippt_icon.png","LICENSE","pop.html","README.md"],
"permissions" : ["tabs", "https://*/*", "storage", "http://*/*"],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'unsafe-eval';"
}
Loading