Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JustOff committed May 8, 2018
1 parent 40f94c4 commit 41b431d
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 0 deletions.
7 changes: 7 additions & 0 deletions chrome.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
content email-this-anywhere content/
skin email-this-anywhere classic/1.0 skin/

overlay chrome://browser/content/browser.xul chrome://email-this-anywhere/content/overlay.xul
overlay chrome://navigator/content/navigator.xul chrome://email-this-anywhere/content/overlay.xul

style chrome://global/content/customizeToolbar.xul chrome://email-this-anywhere/skin/style.css
82 changes: 82 additions & 0 deletions content/overlay.xul
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://email-this-anywhere/skin/style.css" type="text/css"?>
<!DOCTYPE overlay>

<overlay id="email-this-anywhere-Overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<script type="application/x-javascript" src="chrome://email-this-anywhere/content/script.js"/>

<window id="main-window">
<commandset id="commandset">
<command id="cmd_email-this-Gmail" oncommand="emailthisanywhere.GmailFunc()"/>
<command id="cmd_email-this-Yahoo" oncommand="emailthisanywhere.YahooFunc()"/>
<command id="cmd_email-this-GoogleApps" oncommand="emailthisanywhere.GoogleAppsFunc()"/>
<command id="cmd_email-this-MailTo" oncommand="emailthisanywhere.MailToFunc()"/>
</commandset>

<keyset id="mainKeyset">
<key id="key_email-this-Gmail" command="cmd_email-this-Gmail" modifiers="alt,accel" key="g"/>
<key id="key_email-this-Yahoo" command="cmd_email-this-Yahoo" modifiers="alt,accel" key="y"/>
<key id="key_email-this-GoogleApps" command="cmd_email-this-GoogleApps" modifiers="alt,accel" key="a"/>
<key id="key_email-this-MailTo" command="cmd_email-this-MailTo" modifiers="alt,accel" key="k"/>
</keyset>

<keyset id="navKeys">
<key id="key_email-this-Gmail" command="cmd_email-this-Gmail" modifiers="alt,accel" key="g"/>
<key id="key_email-this-Yahoo" command="cmd_email-this-Yahoo" modifiers="alt,accel" key="y"/>
<key id="key_email-this-GoogleApps" command="cmd_email-this-GoogleApps" modifiers="alt,accel" key="a"/>
<key id="key_email-this-MailTo" command="cmd_email-this-MailTo" modifiers="alt,accel" key="k"/>
</keyset>
</window>

<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="gmail-this-button-1"
label="Gmail This!"
tooltiptext="GMail This!"
command="cmd_email-this-Gmail"
class="toolbarbutton-1 chromeclass-toolbar-additional"
key="key_email-this-Gmail"
/>

<toolbarbutton id="yahoo-this-button-1"
label="Yahoo This!"
tooltiptext="Yahoo This!"
command="cmd_email-this-Yahoo"
class="toolbarbutton-1 chromeclass-toolbar-additional"
key="key_email-this-Yahoo"
/>

<toolbarbutton id="googleapps-this-button-1"
label="Google-Apps This!"
tooltiptext="GoogleApps This!"
command="cmd_email-this-GoogleApps"
class="toolbarbutton-1 chromeclass-toolbar-additional"
key="key_email-this-GooglApps"
/>

<toolbarbutton id="mailto-this-button-1"
label="Mail-To This!"
tooltiptext="Mail-To This!"
command="cmd_email-this-MailTo"
class="toolbarbutton-1 chromeclass-toolbar-additional"
key="key_email-this-MailTo"
/>
</toolbarpalette>

<popup id="email-this-anywhere-menu">
</popup>

<popup id="contentAreaContextMenu">
<menuseparator/>
<menu id="email-this-anywhere-menu" label="Email This Anywhere!">
<menupopup id="email-this-anywhere-menu" label="Email This Anywhere!">
<menuitem insertafter="Properties" label="Gmail This!" command="cmd_email-this-Gmail" accesskey="g" key="key_email-this-Gmail" />
<menuitem insertafter="Properties" label="Yahoo This!" command="cmd_email-this-Yahoo" accesskey="y" key="key_email-this-Yahoo" />
<menuitem insertafter="Properties" label="Google-Apps This!" command="cmd_email-this-GoogleApps" accesskey="a" key="key_email-this-GoogleApps" />
<menuitem insertafter="Properties" label="Mail-To This!" command="cmd_email-this-MailTo" accesskey="m" key="key_email-this-MailTo" />
</menupopup>
</menu>
</popup>

</overlay>
45 changes: 45 additions & 0 deletions content/preferences.xul
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<prefwindow id="email-this-anywhere-prefs" title="Email This Anywhere! Preferences"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<prefpane id="email-this-anywhere-options">
<preferences>
<preference id="yahoo_options" name="extensions.email-this-anywhere.yahoo_options" type="string"/>
<preference id="google_apps" name="extensions.email-this-anywhere.google_apps" type="string"/>
</preferences>
<tabbox id="tabbox" flex="1">
<tabs>
<tab id="yahooTab" label="Yahoo Options"/>
<tab id="googleTab" label="Google Apps Options"/>
</tabs>
<tabpanels flex="1">
<tabpanel id="yahooTabpanel">
<vbox>
<text value="Customize Email This! for Yahoo" style="font-weight: bold;"/>
<separator class="thin"/>
<label control="normal" value="Enter your Yahoo Country and Server Info. "/>
<text value="1) Login to Yahoo Mail Classic and look at the Url/Addres Bar" style="font-size: 11px;"/>
<text value="2) You should see something similar to: http://us.mc590.mail.yahoo.com/mc/ or http://us.mc590.mail.yahoo.com/ym/" style="font-size: 11px;"/>
<text value="3) Not everyone will have us.mc590 before mail.yahoo.com" style="font-size: 11px;"/>
<text value="4) Not everyone will have /mc/ or /ym/ after mail.yahoo.com" style="font-size: 11px;"/>
<text value="5) Write in everything you see in the address bar through the mc/ or ym/ (without http://)" style="font-size: 11px;"/>
<text value="6) For instance, I would write in us.mc590.mail.yahoo.com/mc/ (and nothing else following it)" style="font-size: 11px;"/>
<text value="7) Make sure there is an / at the end your input in the text box." style="font-size: 11px;"/>
<textbox preference="yahoo_options"/>
</vbox>
</tabpanel>
<tabpanel id="googleTabpanel">
<vbox>
<text value="Customize Email This! for Google Apps" style="font-weight: bold;"/>
<separator class="thin"/>
<label control="normal" value="Enter your GoogleApps Domain URL/Address (without the http://www.): "/>
<textbox preference="google_apps"/>
</vbox>
</tabpanel>
</tabpanels>
</tabbox>
</prefpane>

</prefwindow>
102 changes: 102 additions & 0 deletions content/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
if (typeof emailthisanywhere == "undefined") {

var emailthisanywhere = {
getSelectedText: function(){
var textWindow = document.commandDispatcher.focusedWindow;
var text = textWindow.getSelection();
if (text == null) {
text =' ';
}
text = text.toString();
text = text.replace(/^\s*$/ , "");
text = text.replace(/\r/g, "\r");
text = text.replace(/\n/g, "\n");
text = text.replace(/^\s+|\s+$/g , " ");
text = text.replace(new RegExp(/\u2019/g), "'");
text = text.replace(new RegExp(/\u201A/g), ",");
text = text.replace(new RegExp(/\u201B/g), "'");
return {str:text};
},

GmailFunc: function(){
var summary ='';
var selectedObj = this.getSelectedText();
if (selectedObj.str) {
summary = selectedObj.str;
}
var createtab = gBrowser.loadOneTab('https://mail.google.com/mail/?view=cm&tf=1&to=&su='+encodeURIComponent(content.document.title)+'&body='+encodeURIComponent(content.location.href)+ '%0D%0A' + '%0D%0A' +encodeURIComponent(summary)+'');
gBrowser.selectedTab = createtab;
},

GoogleAppsFunc: function(){
var domainName = Services.prefs.getCharPref("extensions.email-this-anywhere.google_apps");
var summary ='';
var selectedObj = this.getSelectedText();
if (selectedObj.str) {
summary = selectedObj.str;
}
var createtab = gBrowser.loadOneTab('https://mail.google.com/a/' + domainName + '/?view=cm&tf=1&to=&su='+encodeURIComponent(content.document.title)+'&body='+encodeURIComponent(content.location.href)+ '%0D%0A' + '%0D%0A' +encodeURIComponent(summary)+'');
gBrowser.selectedTab = createtab;
},

YahooFunc: function(){
var options = Services.prefs.getCharPref("extensions.email-this-anywhere.yahoo_options");
var summary ='';
var selectedObj = this.getSelectedText();
if (selectedObj.str) {
summary = selectedObj.str;
}
var createtab2 = gBrowser.loadOneTab('http://' +options+ 'compose?&To=&Subj='+encodeURIComponent(content.document.title)+'&Content='+encodeURIComponent(content.location.href)+ ' --- ' +encodeURIComponent(summary)+'');
gBrowser.selectedTab = createtab2;
},

MailToFunc: function () {
var selectedObj = this.getSelectedText(838860800);
var tx = "";
if (selectedObj.str) {
tx = selectedObj.str;
}
var doc = window.content.document;
var title = doc.title;
var body = doc.URL + "\n"+ tx;
var hasIntegratedMailClient = ("@mozilla.org/messengercompose/composeparams;1" in Components.classes);
if (hasIntegratedMailClient) {
var params = Components.classes["@mozilla.org/messengercompose/composeparams;1"]
.createInstance(Components.interfaces.nsIMsgComposeParams);
params.composeFields = Components.classes['@mozilla.org/messengercompose/composefields;1']
.createInstance(Components.interfaces.nsIMsgCompFields);
params.composeFields.subject = title;
if (tx) {
params.composeFields.body = body;
} else {
params.composeFields.body = doc.URL;
params.bodyIsLink = true;
var attachmentData = Components.classes["@mozilla.org/messengercompose/attachment;1"]
.createInstance(Components.interfaces.nsIMsgAttachment);
attachmentData.url = doc.URL;
attachmentData.urlCharset = doc.characterSet;
params.composeFields.addAttachment(attachmentData);
}
var composeService = Components.classes["@mozilla.org/messengercompose;1"]
.getService(Components.interfaces.nsIMsgComposeService);
try {
params.identity = composeService.defaultIdentity;
}
catch (ex) {
params.identity = null;
}
composeService.OpenComposeWindowWithParams(null, params);
} else {
var extProtocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
.getService(Components.interfaces.nsIExternalProtocolService);
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var body = encodeURIComponent(doc.URL)+ '%0D%0A' + '%0D%0A' + encodeURIComponent(tx) + '';
var mailto = "mailto:?subject="+encodeURIComponent(title)+"&body="+body;
var uri = ioService.newURI(mailto, null, null);
extProtocolSvc.loadUrl(uri);
}
}
}

};
2 changes: 2 additions & 0 deletions defaults/preferences/preferences.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pref("extensions.email-this-anywhere.yahoo_options", "");
pref("extensions.email-this-anywhere.google_apps", "");
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions install.rdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version='1.0' encoding='utf-8'?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>email-this-anywhere@Off.JustOff</em:id>
<em:version>1.0.1</em:version>
<em:type>2</em:type>
<em:name>Email This Anywhere!</em:name>
<em:description>Send your recipient the link, title, and a selected summary of the web page you are viewing</em:description>
<em:creator>Off JustOff &lt;Off.Just.Off@gmail.com&gt;</em:creator>
<em:contributor>Arthur Sabintsev &lt;arthur@sabintsev.com&gt;</em:contributor>
<em:contributor>Shawn Branch</em:contributor>
<em:contributor>Philip Chee</em:contributor>
<em:homepageURL>https://github.com/JustOff/email-this-anywhere/</em:homepageURL>
<em:optionsURL>chrome://email-this-anywhere/content/preferences.xul</em:optionsURL>

<em:targetApplication>
<Description>
<em:id>{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}</em:id>
<em:minVersion>24.0</em:minVersion>
<em:maxVersion>28.*</em:maxVersion>
</Description>
</em:targetApplication>

<em:targetApplication>
<Description>
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
<em:minVersion>2.24</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>
Binary file added skin/gapps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added skin/gmail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added skin/mailto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions skin/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#gmail-this-button-1 {
list-style-image: url("chrome://email-this-anywhere/skin/gmail.png");
}

#yahoo-this-button-1 {
list-style-image: url("chrome://email-this-anywhere/skin/yahoo.png");
}

#mailto-this-button-1 {
list-style-image: url("chrome://email-this-anywhere/skin/mailto.png");
}

#googleapps-this-button-1 {
list-style-image: url("chrome://email-this-anywhere/skin/gapps.png");
}
Binary file added skin/yahoo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 41b431d

Please sign in to comment.