Branding Regular GMail for New Address - gmail

So, with Gmail adding support for 3rd party SMTP servers, and my lame work email system supporting email forwarding, the logical thing for me to do was to start a gmail box for my work, forward to it from work, and setup my work SMTP (none of that "sent on behalf of" garbage anymore.)
I figured out how to replace the Gmail logo with my company's logo using a Greasemonkey script, and figured out how to replace the "Loading blah#gmail.com" with "Loading my work#email.com)
What I haven't been able to crack, however, is getting the blah#gmail.com address on the top bar to be 'switched' to my new email address (even if only for show). I used a Replace text script, but apparently it doesnt work on JavaScript (when I ran it on the HTML version, it replaced the text, but who wants to replace the HTML version)
LONG STORY SHORT**: Does anyone know of a way I can, using Greasemonkey or something similar, change what email address displays on the top of my gmail window?** (next to 'Offline | Older Version | Help | Report Gmail bug | Sign OUt')

If you own the domain at your work you can register it with google apps http://www.google.com/apps/intl/en/group/index.html and then set your MX servers to google and use their gmail (with your logos) there.
If you don't own the domain, I would NOT recommend forwarding your company email to gmail. I know my company gets very grumpy when my corpoate email leaves their servers.

Javascript for your solution:
// ==UserScript==
// #name Gmail Replace Domain
// #author http://codejoust.com
// #namespace http://mail.google.com/
// #description example script to alert "Hello world!" on every page
// #include http://mail.google.com/*
// ==/UserScript==
var your_domain = 'yourdomain.com';
var canvas_frame = document.getElementById('canvas_frame').contentWindow.document;
var user_id = canvas_frame.getElementById('guser').getElementsByTagName('b')[0];
user_id.innerHTML = user_id.innerHTML.replace('gmail.com',your_domain);
As a gist.

Related

How to fix: Trying to capture a data in the options section of chrome extension for local.storage and use elsewhere?

I'm making a Google Chrome extension that has various parts. It has an iframe, a pop-up and an options page. Currently the iframe and pop-up communicate fine and send the collected data off to a database. However I want to capture some data from the options page (an email address) to be used elsewhere in the app. I planned to do this through capturing the email address and storing it but the code doesn't seem to be working.
I've attached the code I'm trying to use in options.js
function save_email(){
var email = document.getElementById('email').value;
chrome.storage.sync.set({
userEmail: email} );
};
I would hope to see it in local/session storage but nothing is there.

Netsuite, how to show popup after login into netsuite account?

I am new to Netsuite and I have a requirement to show one alert message displaying "welcomeuser" after the user loggedin into Netsuite account.
I have tried this client script but its not showing any message.
function employee_PageInit(type){
debugger;
alert('Dear UserName, The data in NetSuite is confidential and the property of the company.');
nlapiLogExecution('DEBUG', 'user role', nlapiGetContext().getName());
alert('ok'+ nlapiGetContext().getName());
}
I have logged in with the role ADMINISTRATOR,
any help is appreciated thank you.
Here is a sample with 2.0. It's not pretty and would need some work. But this is one way to inject javascript logic onto the homepage with a portlet.
/**
*#NApiVersion 2.x
*#NScriptType Portlet
*/
define(['N/runtime'],
function(runtime) {
function render(params) {
var user = runtime.getCurrentUser();
params.portlet.title = 'Welcome Message';
var content = '<script>alert(\'Hello ' + user.name + '\');</script>';
params.portlet.html = content;
}
return {
render: render
};
});
U can try using custom portlet it stands out in the dashboard for showing the content.Then also alert is not possible.
I've struggled with this idea in the past and what you want is not technically possible, since there are no scripts that run when you are viewing the homepage. Here are some weird workarounds:
Schedule a calendar reminder, which can trigger a pop-up with your message.
Before assigning their full NetSuite rights, tell users to go to a specific page or form: Maybe a custom record... (the record could serve as a log of who consented to and read your policy) On this form you could have your message. Then when the user fills it out, have a back-end script enable their permissions.
Make your text into a tiny image, and make it your company logo for all of NetSuite. ;)
You can add the custom Javasript to display the alert on a Suitelet which would be set as the Landing Page under General Preferences, then once the user accepts redirect to their home page, and if they don't accept send an alert to the admin...
E.g.
<script>
var accepted = confirm('Dear UserName, The data in NetSuite is confidential and the property of the company.');
if (accepted)
window.open('https://99999.app.netsuite.com/app/center/card.nl?sc=-29&whence=');
else
//Send email to admin
</script>
Hi please follow the following steps :
Create a suitelet script - Login Script with pageInit() in clientscript action to alert your welcome message.
Goto Setup > Company > General Preference and under Centers tab add appropriate URL of the Login Script Suitelet's deployment and save the preferences.
Note : You can add different messages to different center's based on the roles in your account.
General Preference > Centers Tab
Hope this solves your issue please revert back if anything is missed.
Basically, the homepage of NetSuite is not scriptable.
There are some ways to check if the record/page is scriptable:
Look up the specific record type in the NetSuite Help Center; specifically on the Records Browser
On the Browser's developer console, you may run nlapiGetRecordType() and if it returns the record name, it should be scriptable -- please note that the record should be on edit mode for the console tool to run correctly with NetSuite pages
Hope this helps with your development!
you can write a function
function pageInit(type){
var context= nlapiGetContext();
var username = context.getName();
alert(hello+username);
}

Google analytics stores username and password as a part of url

Issue Context:
I am using meteor js for a mobile app.
I have hooked it up with google analytics calls and basically I am using two type of calls:
Screen views
Events
Screen views are just fine, but I'm facing an issue with the events.
When I go to Behavior -> Events -> Screens, in the google analytics dashboard, I can see the URL of every page that has triggered an event under the Screen Name column. My problem is that the page URLs for my login page look something like this:
meteor.local/login?username=*******&password=+++++++&rememberMe=on
Where ******* is an actual username and +++++++ is the corresponding password!
Reason:
Since I have to share this analytics account with multiple people, I do not want this information to be available over here.
Clues:
CLUE 1:
I used to do GET http calls, but I have changed them all to POST and it still has not fixed the issue as I expected it not to pass plain parameters through URL anymore.
CLUE 2:
I've noticed that the default google analytics js framework is working with http and not https. I was wondering if it is calling the analytics server with a GET as well. If so, is there anyway to change that?
CLUE 3:
Here is how I am initiating the GA instance:
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', googleKey, 'auto');
CLUE 4:
I have also noticed that these URLs are getting captured very occasionally. E.g. in the pas 12,500 unique events (about 30,000 total events) it has captured just 9 URLs with the username and password. The remaining 12,491 events have
meteor.local/login
OR
meteor.local/--
OR
localhost/--
as the Screen Name.
CLUE 5:
I have also put 4 "search and replace" global filters on the analytics account to search for this string
meteor.local/.*
and replace it with this one
meteor.local/concealedURI
This does not seem to be working either.
I have added this filter on 4 different fields (Since I still really don't know where the URLs are coming from):
Host Name
Page Title
Referral
Request URI
CLUE 6:
This is how I am calling the GA instance to send the event:
ga('send', 'event', 'button', 'click', eventName);
Okay. So, I had to run a lot of experiments and try out different things to solve this issue.
After trying all the things that I have described in the question, I finally found a way to address this problem.
The main cause of this problem was that I was using a google analytics account set to track an App, to capture the data from an app that was built with meteor js (which basically utilizes cordova).
Using meteor means that my app's screens are actually web pages rendered as a mobile app. It seems like meteor uses URLs to navigate through these screens.
On the other hand, google analytics looks at (and captures) the screen name of an app's page, when an event is triggered from that page. In native apps this screen name will be something similar to "About us", "Contact Us", "Home", etc.
Now since a meteor app is not the same, the screen name returned by meteor is actually the URL of the page that has triggered the event.
This does not have anything to do with the http calls (Whether or not they are GET or POST), because it is the local URL used by meteor for navigating that is being passed down to google analytics and not any http calls.
Solutions
1.
If I had the google analytics account set as a web page tracker, I could have access to "Exclude URL Query Parameters" field and I could potentially exclude username and password as was suggested by #Mike and #PhilipPryde in the comments.
However, I needed to use google analytics set as an app tracker. So, this did not work for me.
Failed
2.
I did put a filter on the whole view in the google analytics and searched for meteor.local/.* and replaced that with hiddenURL. The filters on
Host Name
Page Title
Referral
Request URI
did not work.
But when I put the same filter on
Screen Label
field, it worked.
However, this only looked at the screen names returned by screen view hits and not the event. Thus, this did not actually solve my issue either.
Failed
Finally, I had to do this:
There is a method call on GA instance that lets you set different options up. I ended up using this:
ga('set', 'screenName', 'hiddenURL');
This changed the screen name to "hiddenURL". So, I used this before every event and it worked for me.
My code for sending events to google analytics looked like this:
ga('set', 'screenName', 'hiddenURL');
ga('send', 'event', 'button', 'click', eventName);
PS:
This changes the screen name that was showing up in real-time reports of google analytics to "hiddenURL", whenever someone triggered an event. But, it changes back to a screen name as soon as they go to another page. So, it would not also mess with any of your screen view data either, since it is not being captured as a screen view.
Of course that is because, I pass the screen name to my GA instance every time I send a screen view. So it looks like this:
sendScreenViewToGA = function (screenName) {
ga('send', 'screenview', {
'appName': 'Something',
'screenName': screenName,
'appVersion': x.x
});
}
If I had used the screen name, that is being set on the environment tight now, I would have ended up with all my screen names in analytics set to "hiddenURL".
I really hope this post will help others with same issues and save them some time.

SMS notification for Gmail using Google Apps Scripts: how to display content of the email?

I am working on SMS notification each time I receive an email that meets certain criteria; I decided to use Google App Scripts for this.
I have been inspired in particular by the following article https://developers.google.com/apps-script/articles/gmail_filter_sms. I also checked the related question in StackOverflow SMS Alerts for Important Mails in Gmail.
I improved the original script from developers.google.com by cleaning up the events the next time the script is run (I was receiving the SMS alerts each time the script is run). The script is currently working by using the label 'SendText' and creating events in calendar 'AlertSMS'.
However the SMS I receive only contain the subject and author of the email: I need to display the content of the email (or at least a part of it). I tried with no luck to add it to the description of the event. Anybody got an idea on how to do it?
Hereunder, the code of my script:
function sendText() {
var now = new Date().getTime();
// Delete old events
var events = CalendarApp.openByName('AlertSMS').getEvents(new Date('January 1, 2010 EST'), new Date(now-30000));
for (i in events) {
events[i].deleteEvent();
}
// Get list of emails to set alert for
var label = GmailApp.getUserLabelByName('SendText');
var threads = label.getThreads();
// Create new events for emails alert
for(i in threads){
var message=threads[i].getMessages()[0];
CalendarApp.openByName('AlertSMS').createEvent('[SMS] '+threads[i].getFirstMessageSubject()+' -from- '+message.getFrom(),
new Date(now+60000), new Date(now+60000), { description:message.getBody() }).addSmsReminder(0);
}
label.removeFromThreads(threads);
}
You can use services such as (the completely free) IFTTT or (the somewhat free) Zapier to trigger an SMS action upon receiving emails matching a criteria.
Here are some IFTTT "recipes" which connect GMail to SMS.
You don't really need the Calendar hack to send arbitrary text messages to yourself - every mobile provider has an email to text gateway. For verizon, for example, its 5551234567#vtext.com (substitute your phone number) and there exists similar for other carriers. Just use GmailApp to email those numbers and you can send whatever you want.

Change a document's permissions via Google Apps Script

I'm looking for sample script that resets the default permissions on an external spreadsheet based on the email address and DocumentID passed to the script. I intent to create a script that can parse information from an email message to acquire the DocumentID and email, execute the permission change from default to anyone with a link, then email the passed address with that link.
It appears that perms are controlled by the DocList API and I'm not finding samples of GAS interacting with that API.
At Google I/O 2013, DriveApp was launched. This allows developers to build use cases like Sharing to Anyone with link
https://developers.google.com/apps-script/reference/drive/
Sample code -
var quizTemplate = DriveApp.getFileById(QUIZ_TEMPLATE_ID);
quizTemplate.setSharing(DriveApp.Access.DOMAIN_WITH_LINK, DriveApp.Permission.VIEW);
or
var openFile = DriveApp.getFileById(WIDE_OPEN_ID)
openFile.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.COMMENT);
AFAIK DocsList Services does not have a function to change the sharing mode, between private/anyone with a link/public, only to add/remove editors and viewers. But we can still achieve this by previously setting manually the share settings of a specific folder to "anyone with a link". Then, we have just to add the file to that folder to have it shared.
A script to do that is particularly simple. e.g.
function shareWithAnyoneAndEmail(documentID,email) {
var sharedFolder = DocsList.getFolderById('id-to-your-previously-shared-folder');
var file = DocsList.getFileById(documentID);
file.addToFolder(sharedFolder);
MailApp.sendEmail(email, 'Here is your file', file.getName()+'\n'+file.getUrl());
}

Resources