Permalink
Browse files

Start Opera port

  • Loading branch information...
1 parent 014943a commit 5cc7aecde2b84f04eee2525e351824b62ea51ba5 @jcutler committed Dec 20, 2011
Showing with 283 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +13 −0 opera/config.xml
  3. +89 −0 opera/extension.js
  4. +30 −0 opera/includes/start.js
  5. +126 −0 opera/index.html
  6. +16 −0 opera/jquery.min.js
  7. +4 −0 setenvironment.sh
View
@@ -3,18 +3,23 @@ syncDirs.sh
temporary
chrome/core
missinge.safariextension/core
+opera/core
firefox/missinge/data/core
chrome/license
missinge.safariextension/license
+opera/license
firefox/missinge/data/license
chrome/identity
missinge.safariextension/identity
+opera/identity
firefox/missinge/data/identity
chrome/lib
missinge.safariextension/lib
+opera/lib
firefox/missinge/data/lib
build/chrome-build
build/firefox-build
+build/opera-build
build/safari-build
firefox/missinge/lib/localizations.js
firefox/missinge/lib/utils.js
View
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<widget xmlns="http://www.w3.org/ns/widgets" id="http://missinge.infraware.ca" version="3.0">
+ <name short="missing-e">Missing e</name>
+ <description>Useful features and customizations for Tumblr.</description>
+ <author href="http://missinge.infraware.ca" email="missinge@infraware.ca">Jeremy Cutler</author>
+ <icon src="identity/missinge128.png"/>
+ <icon src="identity/missinge64.png"/>
+ <icon src="identity/missinge32.png"/>
+ <license href="http://www.gnu.org/licenses/gpl-3.0-standalone.html">
+ Licensed under the GNU General Public License version 3 or higher
+ </license>
+ <access origin = "*" />
+</widget>
View
@@ -0,0 +1,89 @@
+/*
+ * 'Missing e' Extension
+ *
+ * Copyright 2011, Jeremy Cutler
+ * Released under the GPL version 3 licence.
+ * SEE: license/GPL-LICENSE.txt
+ *
+ * This file is part of 'Missing e'.
+ *
+ * 'Missing e' is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 'Missing e' is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with 'Missing e'. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*global chrome, extension, MissingE */
+
+(function(){
+
+if (typeof MissingE !== "undefined") { return; }
+
+MissingE = {
+ packages: {},
+ utilities: {
+ exportSettings: function(callback) {
+ },
+
+ importSettings: function(input) {
+ }
+ }
+};
+
+extension = {
+ isChrome: false,
+ isFirefox: false,
+ isOpera: true,
+ isSafari: false,
+ _ajaxListeners: null,
+ _listeners: null,
+
+ _hasAjaxListener: function(func) {
+ },
+
+ _hasListener: function(name, func) {
+ },
+
+ _registerAjaxListener: function() {
+ },
+
+ _registerListener: function() {
+ },
+
+ addAjaxListener: function(func) {
+ },
+
+ addListener: function(name, func) {
+ },
+
+ getURL: function(rel) {
+ },
+
+ hasBaseURL: function() {
+ },
+
+ insertStyleSheet: function() {
+ },
+
+ openWindow: function(addr) {
+ },
+
+ removeAjaxListener: function(func) {
+ },
+
+ removeListener: function(name, func) {
+ },
+
+ sendRequest: function(name, request, callback) {
+ }
+};
+
+}());
View
@@ -0,0 +1,30 @@
+// ==UserScript==
+// @include http://*
+// ==/UserScript==
+
+window.addEventListener("DOMContentLoaded", function() {
+ var i;
+ var channel = new MessageChannel();
+
+ channel.port1.onmessage = function(evt) {
+ if (evt.data.greeting === "initialize") {
+ var head = document.getElementsByTagName("head")[0];
+ var headChild = head.firstChild;
+ var files = evt.data.files;
+ for (i=0; i<files.css.length; i++) {
+ var x = document.createElement("style");
+ x.textContent = files.css[i];
+ head.insertBefore(x, headChild);
+ }
+ for (i=0; i<files.js.length; i++) {
+ var y = document.createElement("script");
+ y.textContent = files.js[i];
+ head.appendChild(y);
+ }
+ }
+ };
+
+ opera.extension.postMessage({greeting: "initialize",
+ url: window.location.href},
+ [channel.port2]);
+}, false);
View
@@ -0,0 +1,126 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="jquery.min.js"></script>
+<script>
+
+var imageCache = {};
+
+function getImages(imgs, callback) {
+ var i;
+ var result = {};
+ var imgCount = 0;
+ function onComplete(){
+ if (imgCount >= imgs.length) {
+ callback(result);
+ }
+ }
+ for (i=0; i<imgs; i++) {
+ if (typeof imageCache[img[i]] === "undefined") {
+ var canvas = document.createElement("canvas");
+ var img = document.createElement("img");
+ img.onload = function(){
+ var idx;
+ canvas.height = img.height;
+ canvas.width = img.width;
+ var context = canvas.getContext("2d");
+ context.drawImage(img, 0, 0, img.width, img.height);
+ imageCache[img.src] = canvas.toDataURL();
+ result[img.src] = imageCache[img.src];
+ imgCount++;
+ onComplete();
+ };
+ img.src = imgs[i];
+ }
+ else {
+ result[imgs[i]] = imageCache[imgs[i]];
+ imgCount++;
+ onComplete();
+ }
+ }
+}
+
+function getFiles(files, callback) {
+ var i;
+ var result = {
+ "css": [],
+ "js": []
+ };
+ var cssCount = 0, jsCount = 0;
+ function onComplete(){
+ if (jsCount >= files.js.length && cssCount >= files.css.length) {
+ callback(result);
+ }
+ }
+
+ for (i=0; i<files.css.length; i++) {
+ $.ajax({
+ url: files.css[i],
+ context: files.css[i],
+ dataType: "text",
+ success: function(data) {
+ var idx = $.inArray(this.toString(), files.css);
+ if (idx >= 0) {
+ result.css[idx] = data;
+ }
+ },
+ complete: function() {
+ cssCount++;
+ onComplete();
+ }
+ });
+ }
+ for (i=0; i<files.js.length; i++) {
+ $.ajax({
+ url: files.js[i],
+ context: files.js[i],
+ dataType: "text",
+ success: function(data) {
+ var idx = $.inArray(this.toString(), files.js);
+ if (idx >= 0) {
+ result.js[idx] = data;
+ }
+ },
+ complete: function() {
+ jsCount++;
+ onComplete();
+ }
+ });
+ }
+}
+
+opera.extension.onmessage = function(e) {
+ if (e.data.greeting === "initialize" &&
+ /http:\/\/www\.tumblr\.com/.test(e.data.url)) {
+ var result = {
+ "css": [],
+ "js": []
+ };
+ var files = {
+ "css": [],
+ "js": ["extension.js",
+ "core/localizations.js",
+ "core/utils.js",
+ "core/common/menuButton.js"]
+ };
+ getFiles(files, function(result) {
+ e.ports[0].postMessage({greeting: "initialize",
+ files: result});
+ });
+ }
+ else if (e.data.greeting === "addMenu") {
+ getFiles({"css": ["core/common/menuButton.css"]}, function(result) {
+ e.ports[0].postMessage({greeting: "sendFiles",
+ {"core/common/menuButton.css":
+ result.css[0]}});
+ getImages(["identity/missinge_dash.png"], function(result) {
+ e.ports[0].postMessage({greeting: "sendImages", imgs: result});
+ });
+ });
+ }
+};
+
+</script>
+</head>
+<body></body>
+</html>
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -16,6 +16,10 @@ for i in $COMMON; do
echo "Creating junction for Firefox: $i"
junction $CWD/firefox/missinge/data/$i $CWD/$i
fi
+ if [[ ! -e "$CWD/opera/$i" ]]; then
+ echo "Creating junction for Opera: $i"
+ junction $CWD/opera/$i $CWD/$i
+ fi
done
if [[ ! -f "$CWD/firefox/missinge/lib/localizations.js" ]]; then

0 comments on commit 5cc7aec

Please sign in to comment.