在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:KartikTalwar/gmail.js开源软件地址:https://github.com/KartikTalwar/gmail.js开源编程语言:JavaScript 100.0%开源软件介绍:Gmail.js - JavaScript API for GmailWhat Gmail.js is and isn'tGmail.js is meant to be used for creating WebExtension-based browser-extensions, for Chrome, Firefox and other compatible browsers. It cannot be used server-side with Node, or from another web-app to interface with Gmail. Note: This is not an official Gmail API, and isn't affiliated with Google. Note: Gmail.js requires jQuery to work TL;DR Summary
Using Gmail.jsIf you know how to create WebExtensions-based extensions for Firefox and Chrome, you can get started by pulling Gmail.js like this:
Note: Please ensure that Gmail.js is injected into the regular DOM. Content-scripts which launch injected script must be configured with It's recommended to split injected script to have only gmail.js load first because the size of the injected script impacts the loading time. Gmail.js must be injected and loaded before Gmail loads embedded data. Gmail.js does not work as a content-script. For a ready to use example/boilerplate repo, look no further:
Content Security Policy (legacy advice)In earlier advice given w.r.t. deployment of GmailJS, where scripts were injected one by one, with cumbersome loading and probing mechanisms, CSP could be an problem causing your extension to fail if GmailJS was injected incorrectly. If you use modern javascript and script-bundling in your extension (like in the boilerplate example), CSP will not interfere with loading of your extension, nor GmailJS. If you have any issues with CSP, the general advice is to build your extension using script-bundling and eliminate the cause of the error all together. While you may be able to make it work, legacy loading is no longer considered supported by GmailJS. TypescriptUsing gmail-js with TypeScript is relatively easy, but if you use normal const GmailFactory = require("gmail-js");
const gmail = new GmailFactory.Gmail() as Gmail;
// working on the gmail-object now provides type-safety. You will also have to import the types somewhere, like in a file called import "gmail-js"; MethodsSummary (click for more info)GET
GET (deprecated methods)
CHECK
CHATCOMPOSEOBSERVE
DOMThese methods return the DOM data itself
TOOLSThese are some helper functions that the rest of the methods use. See source for input params
TRACKERThese are some of the variables that are tracked and kept in memory while the rest of the methods are in use.
Detailsgmail.new.get.email_id()Obtains the new-style email-ID from the email currently on screen. Extracted via DOM. This ID can only be used by Can be provided email-element from HTML DOM, or Gmail DOMEmail object to look up specific email ID. gmail.new.get.thread_id()Obtains the new-style thread-ID from the email currently on screen. Extracted via DOM. This ID can only be used by gmail.new.get.email_data(identifier)Returns a data-object for the requested email, if found in the email-cache.
If no email-data can be found in Gmail.JS email-cache,
This method returns immediately, uses no XHR, and has no async-equivalent. Please note: Email-data is intercepted and stored in the cache only when Gmail itself has requested or used and email. This typically happens when loading a label (pre-loading all emails in view) or when navigating to view a full thread. That means that calling the same method later may return data even if
the first invocation returned {
"id": "msg-f:1581064946762017791",
"legacy_email_id": "15f1123136926bff",
"thread_id": "thread-f:1581064946762017791",
"smtp_id": "<[email protected]>",
"subject": "[PATCH] Flymake support for C/C++",
"timestamp": 1507821032297,
"content_html": "Hi,<br>\n<br>\nHere's a proposal for supporting Flymake in C/C++. This patch...",
"date": "2017-10-12T15:10:32.297Z",
"from": {
"address": "[email protected]",
"name": ""
},
"to": [
{
"address": "[email protected]"
}
],
"cc": [
{
"address": "[email protected]"
},
{
"address": "[email protected]"
}
],
"bcc": [],
"attachments": [
{
"attachment_id": "0.1",
"name": "0001-Add-a-Flymake-backend-for-C.patch",
"type": "application/x-patch",
"url": "https://mail.google.com/mail/?ui=2&ik=94da28fb67&attid=0.1&permmsgid=msg-f:1581064946762017791&th=15f1123136926bff&view=att&zw",
"size": 11225
}
]
} gmail.new.get.thread_data(identifier)Returns a data-object for the requested email-thread, if found in the email-cache.
If no thread-data can be found in Gmail.JS email-cache,
This method returns immediately, uses no XHR, and has no async-equivalent. Please note: Email-data is intercepted and stored in the cache only when Gmail itself has requested or used and email. This typically happens when loading a label (pre-loading all emails in view) or when navigating to view a full thread. That means that calling the same method later may return data even if
the first invocation returned {
"thread_id": "thread-f:1581064946762017791",
"emails": [...email_data elements...]
} gmail.get.email_source(identifier=undefined)Deprecated function. Will be removed. Migrate to
gmail.get.email_source_async(identifier=undefined, callback, error_callback, preferBinary=false)Retrieves raw MIME message source from the gmail server for the specified email identifier.
If not specified, current email will be resolved automatically. By default, once retrieved the resulting data will be passed to
If you need to parse this data in a proper MIME-parser later, the only way to avoid this kind of error is to download the data in binary format and do your own decoding inside your own MIME-parser. To get the email-source in binary form, you must set the
gmail.get.email_source_promise(identifier=undefined, preferBinary=false)Does the same as above but implements it using ES6 promises. gmail.get.user_email()Returns the current user's email address gmail.get.manager_email()Returns the email address of the user currently managing the account (if the inbox is used by the owner, this function returns the same value as gmail.get**.user_email()**) gmail.get.delegated_to_email()Returns the email address of the user the account is currently delegated to (if the inbox is used by the owner, this function returns null) gmail.get.storage_info()Returns current user's file storage stats {
"used": "0 GB",
"total": "15 GB",
"percent": 0
} gmail.get.current_page()Returns what page of gmail the user is currently on. These are the possible responses ['sent', 'inbox', 'starred', 'drafts', 'imp', 'chats', 'all', 'spam', 'trash', 'circle'] // pages
"email" // inside email conversation
"/search/[.+]" // inside search view
"/label/[.+]" // inside label view
"/category/[.+]" // inside category view
"/settings/[.+]" // settings sub-page (excluding settings root page) gmail.get.email_subject()Returns the opened email's subject from the DOM "test" gmail.get.compose_ids()Returns the latest/last email id of emails that have been saved as drafts (currently open) ["14469c73bba6ff53", "14469c7b8581ccfa"] gmail.get.search_query()Returns the search bar data "from:[email protected] is:unread" gmail.get.unread_emails()Returns a count of total unread emails for the current account. {
"inbox": 2,
"drafts": 0,
"spam": 0,
"forum": 0,
"notifications": 0,
"promotions": 0,
"social": 0
} You can also request the data individually
gmail.get.last_active()Gets user's account activity data {
"time": "9:41 pm",
"ip": "54.234.192.48",
"mac_address": "2620:101:f000:702:a966:ab42:4a46:195e",
"time_relative": "31 minutes ago"
} gmail.get.loggedin_accounts()Returns a list of signed-in accounts (multiple user accounts setup in gmail) [{"name":"California","email":"[email protected]"}] gmail.get.beta()Although hand picked, this method returns the checks on beta features and deployments {"new_nav_bar":true} gmail.get.localization()Returns the Gmail localization, e.g. 'US'. gmail.check.is_new_data_layer()Returns gmail.check.is_new_gui()Returns |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论