I am writing an application to list or update users using Javascript. I have enabled the relevant API's in dev console. This all works ok if I use AdminDirectory.Users.list, however when I try to get a single user via AdminDirectory.Users.get and pass the google ID as the key, I get Login Required.
I have tried to add option .viewType = "domain_public" but to no avail.
For now, Im going to re-write the local function that uses .get to get the user via list, but would like to know if anyone else has this problem or know how to fix it.
I ran into the same issue when I tried to write a custom function to retrieve the users in our directory. After reading Paul's comment, I checked and found that custom functions operate with same minimal permissions, so I also added a custom menu to load the users.
At risk of giving advice without testing it myself: for triggers, you'll need to use an event with an authMode value of FULL.
See the Google Apps Script Event Objects guide.
Related
I am building an extension in Thunderbird with UI element message_display_action for my school project. I am wondering if I can access full email source code from java script file that I am using for building up my html page when pressing on button my extension. I found a funciton named getFull(messageId) in documentation at https://webextension-api.thunderbird.net/ but I don't understand how to use that function and I don't even know what messageId is. I know it is a integer but I don't know how to get that integer for a specific email. I entered permission (messagesRead) in my manifest file of extension for reading emails but i still don't know how to use that function. I didn't find any examples or tutorials on the internet so if anyone can help me or atleast point me to the right direction.
Getting the id of the currently displayed message
You should take a look at https://github.com/thundernest/sample-extensions/tree/master/messageDisplay, which is an example how to get the id of the currently displayed message from the messageDisplayAction using messageDisplay.getDisplayedMessage().
See also https://webextension-api.thunderbird.net/en/latest/messageDisplay.html.
messages.getFull()
Didn't find a small example using that API. As a hint you should note that this function works on the different MIME parts a mail consists of.
You will not get the complete source of the email that way. To get the raw source you would need to use messages.getRaw(). But you should probably not use getRaw() unless you really need it, because you would need to handle the complete parsing of the message yourself.
Apologies if that's the wrong place, but have no clue where to ask.
We are building Firefox addon that works on selected websites. Now, because those websites tend to change once in a while, I want to run once a day a javascript script that will check whether the specific part of code has been changed, and if it did, we would get some return message (ideally directly to my email).
What would be the easiest, simplest way to do that? I've read about webcrawlers, webscrapers, but they seem to be doing far more than we need. We basically want to run from our PCs connected to internet a small script that will do that simple check and send us email as soon as the change to the specific part of html body has been detected (or to be more specific - selected elements have not been found).
Any help greatly appreciated
Basically you might set up Google Spreadsheet to scrape pages' parts thru IMPORTXML function (here with an example) using xpath. Then you set up notifications in a spreadsheet: Tools -> Notification Rules
Now each time the scraping function (IMPORTXML) gets content that is different to previous one, spreadsheet should trigger a mail to you.
As an off-the-shelf alternative I also might recommend some tools that track pages' and/or their parts'(!) changes including notifying by email.
I'm currently working on a PHP 5.3 based CMS. A lot of actions are called using GET Parameters.
Example:
index.php?action=create_module
adds a certain module to the database and displays the module structure again. There are also functions (triggered by simple links, no POST request) for removing and ordering modules, working the same way with GET parameters.
Problem with this: If the users clicks on History Back after two actions on that page, the whole action is triggered again, which I would like to avoid.
How can I solve this issue? Searched the internet already, but with no satisfying results.
Is there a jQuery function which can remove this ?action parameter when using the browser Back button?
If not, can I prevent the browser from going back?
Is there a way to trigger this "Page has expired" notice?
Different approach on the PHP side?
Note: Header("Location:..") is no option, and I would like to avoid AJAX here.
Thank you for your help!
You could add an event listener on 'onpopstate' to clean window.location.search which holds the parameters, see http://html5doctor.com/history-api/ to get more info about HistoryAPI.
I'm trying to retrieve some information from Gmail but have been unsuccessful after many attempts. This is the line of code that I'm trying to extract using javascript.
Inbox (182)
Im trying to get the text "Inbox (182)," to do that, I'm using this piece of code
NSString *js_result = [webview1 stringByEvaluatingJavaScriptFromString:#"document.getElementsByClassName('J-Ke n0').innerText"];
This however does not work, my result being nothing at all, and I've tried many alternatives but none have worked. All I need to do here is extract the "Inbox (182)" text in any way possible. Thanks.
I think your javascript is incorrect, since there are multiple elements with that class. If I login to gmail, this works:
document.getElementsByClassName('J-Ke n0')[0].innerText
I would be weary of using this in a production environment, though. It seems very brittle; that class or order of elements could be changed by Google at any time.
You also need to make sure that the page has loaded before trying to execute javascript. Typically this is implemented in a webViewDidFinishLoad: callback. If you're not getting a result and your JS is valid, this is probably the issue.
Now, this requirement may seem weird. But i would like to know how to achieve this?
I am having an HTML file, which is having few input box, check box, radio button etc. I would like to retain the changes a user [ actually i ] performs on this page. Like if the user has ticked a checkbox then next time anybody open that file should see that checkbox as ticked.
This thing can be done easily using HTTP cookies. But i don't want to use cookies.
The answer can be as simple as "No you can not do that" :)
Edit
That's the problem with not phrasing the question correctly.
I guess i can't use DB as if i will send my HTML page to someone then he/she will not be able to see my changes. I want my changes to be reflected on other systems also. [ thats the reason i was not going for cookies ]. Other solution what i was thinking was, using FileSystemObject. Any other solution ? again the answer can be "No you can not do that" :D
You could bind the change events of your form elements to an AJAX submit, log the submits to the db and then on any page load grab the latest states from the db for rendering.
Edit
If you want these changes to appear "simultaneously" for other users then you could use jQuery polling to update the page - have the page periodically poll the server for the latest state.
Having said that, if you give them a server link and not the actual file they will see your db changes.
However, it sounds like you want to actually send the file (not send someone to a web server) in which case you could do something like one of these approaches:
Your PHP/whatever file (can possibly even do this with javascript) outputs a HTML file with appropriate checked="checked", selected="selected", value="blah" etc. You send this file.
Your PHP/whatever file outputs a static reference file. Your HTML file has javascript referencing and using the values stored in this file. You send both of these files around (although value updates only require a changed static reference file).
I sounds like you want to change the actual file using Javascript - this should be rather difficult. Javascript was designed from scratch as a web scripting language and as such it doesn't have any built in file/IO functionality.
What you can do in Javascript is load ActiveX objects and plug ins. How this works depends a lot on which browser you're using. For instance in IE you could load an ActiveX object (written in VB or whatever) that could edit your file:
var fileWriter = new ActiveXObject("My.FileWriter");
fileWriter.Update("myFile.htm", "inputName", "newValue");
You'd have to write your FileWriter utility though.
Alternatively you could use HTML5's new data storage stuff - but then you're still limited on browser.
You need some method to identify the user when he or she visits again. A browser cookie is useful, because it is stored on the user's computer, which serves as identification. The other serious option is to store the user's preferences in a database. This would, at least, require a server-side language. In addition, you need some way to identify the user, such as username, or, less reliably, IP address.
I hear other options may exist in HTML5, but I don't think those can be used seriously at this time. You can read about it here in Offline Web Applications. It seems to me like something very similar in spirit, although much more powerful, than cookies.