content script - window.location.href = url_b; lands on about:blank page - google-chrome-extension

In my content script
var url_b = 'chrome-extension://abcdefghijklmnopqrstuv/page_b.html';
window.location.href = url_b;
takes me to about:blank instead of chrome file
'chrome-extension://abcdefghijklmnopqrstuv/page_b.html' url is valid and works when opened in a new tab
same code if url_b = 'www.gmail.com'
takes me to gmail. works fine.
to reproduce.
1.open gmail.com in a tab
2.open console and command in 'window.location.href = chrome-extension://any sample file'
3.about:blank opens
4.run step 2 again
5.sample page opens

Related

Safari in fullscreen mode ahref target "_blank" does not open in new window

We have an app that opens in a new window (popup) with defined window size. There are links in the app that open another external links.
We have a code to handle ahref links to open in a new window using target as "_blank".
It works fine with all the browsers except in Safari when the popup window is changed to fullscreen mode. Once in fullscreen mode the external links (even with _blank) open in the same window and replace the content of the main window.
I want to open the external links in a new tab/window always.
Please help.
handleLinks: function (link) {
var url = link.href;
if (url && !url.indexOf('http')) {
link.target = '_blank'
link.rel = 'external';
} else if (url && !url.indexOf('mailto')) {
// FIX FOR CHROME BROWSER NOT TO OPEN IN A BROWSER TAB FOR MAIL CLIENT
link.target = '_top';
}
}

How can I transfer a file from Gmail using an app script by POSTing to a remote server

I'm using google apps scripting to write some addons to link gmail (or g suite email) to our crm system.
My current issue is trying to take a selected attachment, POST to a php script on a remote server which recreates the file (and goes from there to integrate into our crm).
Details of the code etc is below though in essence the file obviously isn't transferring correctly so something is wrong in the way the file is being received, or saved locally. The filesize is different and it won't open. So for example I select a PDF in the email which is 640k and the resulting file created on my server is over 1mb
I've setup my script with a card which includes a radio list of attachments. A button in the card attempts to post the file contents to the remote server where a receiving PHP script just saves it as a local file.
Getting attachment list to produce radio buttons:
var attachmenttosave = CardService.newSelectionInput().setType(CardService.SelectionInputType.RADIO_BUTTON).setTitle("Selected Attachment").setFieldName("attachmenttosave");
for(var i = 0; i < attachments.length; i++) {
var attachment=attachments[i];
attachmenttosave.addItem(attachment.getName(),i,false);
}
code which gets the attachment and POSTs to remote server:
var accessToken = e.messageMetadata.accessToken;
var accessToken = e.messageMetadata.accessToken;
GmailApp.setCurrentMessageAccessToken(accessToken);
var messageId = e.messageMetadata.messageId;
var message = GmailApp.getMessageById(messageId);
var atc=e['formInput'].attachmenttosave;
var attachments=message.getAttachments();
var fn=attachments[parseInt(atc)].getName();
var blob=attachments[parseInt(atc)].getAs(attachments[parseInt(atc)].getContentType());
var url="https://remote.server";
var payload={"typ":"GS_SaveAttachmentToCase","email":encodeURIComponent(user),"fn":encodeURIComponent(fn), 'att':(blob)};
var options={"method":"POST","payload":payload,"followRedirects":true,"muteHttpExceptions":true};
var result=UrlFetchApp.fetch(url, options);
var data = result.getContentText();
return CardService.newActionResponseBuilder().setNotification(CardService.newNotification().setText(data).setType(CardService.NotificationType.INFO)).build();
Receiving PHP script:
`
function GS_SaveAttachmentToCase(){
$fn=urldecode($_POST['fn']);
$fp = fopen("GS/" .$fn, "w+");
fwrite($fp, (utf8_decode ($_POST['att'])));
fclose($fp);
echo "done";
}
`
ok did some more research and solved this.
get the attachment contents using
blob=attachments[parseInt(atc)].getBytes();
in the receiving php script
fwrite($fp, (base64_decode ($_POST['att'])));

How to Email include Notes link to open xpages client

I have problem when sending a notes link to an email in order to open it directly from email client. Does the link i created is invalid? May i know which is a correct way of sending notes link open xpages page?
Question 1. How to open Document in xpages with document ID by clicking notes link?
one way: i understand is at the form Display xpages. May i know still got other way to do it?
Question 2. How to open Xpages Page without document ID for example is like the page that contain view.
My doclink is write as:
var doclink="notes://"+server+"/"+dname.replace(/(\\)/g, "/")+"/"+document1.getDocument().getUniversalID()+"/Request_Form.xsp?OpenXpages"
result come out for that link:
My viewlink is write as:
var viewlink ="notes://" +server+"/"+dname.replace(/(\\)/g, "/")+"/"+"Request_View.xsp?OpenXPage"
result come out for that link:
My server and database name as below
Below will be my script of sending email
var setdoc:NotesDocument = database.getProfileDocument("System Setting", "");
var server = setdoc.getItemValueString("MailDBSvr");
var dname = setdoc.getItemValueString("MailDbPath");
var web = setdoc.getItemValueString("InternetAddress");
var maildoc:NotesDocument = database.createDocument()//mdb.createDocument() //database.createDocument()
maildoc.replaceItemValue("Form", "Memo");
maildoc.replaceItemValue("Subject","Request for Email Account By "+document1.getItemValueString('Name'));
session.setConvertMime(false);
var stream = session.createStream();
stream.writeText("<html><body>");
stream.writeText("<p>Dear " + "department reviewer" + ",</p>");
stream.writeText('<p>Kindly review this request by '+document1.getItemValueString('Name')+" on "+I18n.toString(#Today(), 'dd/MM/yyyy')+ ",</p>");
// open in web (http://devsvr1.pcs.com.my/CN=ServerOne/O=dev!!Brooke%5CBrooke.nsf/Request_Form.xsp?databaseName=CN=ServerOne/O=dev!!Brooke%5CBrooke.nsf&documentId=5FBA577C3DF795AB4825819400274B0A&action=editDocument)
stream.writeText("<p>Please click "+"<a href='http://"+web+"/"+
database.getServer()+"!!"+
XSPUrl.encodeParameter(dname, "UTF-8") +
"/"+"Request_Form.xsp?databaseName="+server+"!!"+
XSPUrl.encodeParameter(dname,"UTF-8") +
"&documentId="+document1.getDocument().getUniversalID()+
"&action=editDocument'>here</a> to open requisition form</p>")
// open in notes client (notes://server/path/database.nsf/pagename.xsp?openXpage)
var doclink="notes://"+server+"/"+dname.replace(/(\\)/g, "/")+"/"+document1.getDocument().getUniversalID()+"/Request_Form.xsp?OpenXpages"
stream.writeText("<p><a href='"+doclink+"'>Click Here</a> if you are in the Notes Client. Thank you.</p>");
stream.writeText("<p>Or</p>");
// open in web (http://devsvr1.pcs.com.my/brooke/brooke.nsf/Request_View.xsp)
stream.writeText("<p>Click <a href='http://"+web+"/"+dname.replace(/(\\)/g, "/")+"/"+"Request_View.xsp?'>here</a> to view all requisitions.</p>");
// Open in notes Client
// #URLOpen("notes://server/Path/database.nsf/XPageName.xsp?OpenXPage")
var viewlink ="notes://" +server+"/"+dname.replace(/(\\)/g, "/")+"/"+"Request_View.xsp?OpenXPage"
stream.writeText("<p><a href='"+viewlink+"'>Click Here</a> if you are in the Notes Client. Thank you.</p>");
stream.writeText("<p> ***THIS IS AN AUTOMATED MESSAGE - PLEASE DO NOT REPLY DIRECTLY TO THIS EMAIL***</p>");
stream.writeText("</body></html>");
var body = maildoc.createMIMEEntity("Body");
body.setContentFromText(stream, "text/html;charset=UTF-8", 1725);
stream.close();
maildoc.closeMIMEEntities(true);
session.setConvertMime(true);
maildoc.replaceItemValue("SendTo",document1.getItemValue("Dep_rev"));
maildoc.send();
document1.getDocument().computeWithForm(true,true);
New update:
You need to change the way you handle the server name. Notes URLs don't use the full canonical name for servers.
So change CN=ServerOne/O=Dev to something the notes:// protocol does support. You could use:
the shortened name ServerOne%2FDev (use #Name[Abbreviate] and replace / with %2f)
the Common name ServerOne (use #Name[CN])
the DNS name www.yourserver.com
the IP address: 165.34.11.34
In all cases you need to make sure that the server name gets properly resolved by the Notes client:
For the shortened name a connection document would do the trick (unless its the default server, then it is auto).
For the Common name it is either a connection document or the DNS resolved it (intranet DNS)
for the DNS name, its DNS (doh)
You really don't want to use IP addresses, but you could
Hope that helps

page object watir cucumber test for file being downloaded

I'm trying to test that a file downloaded is initialized when i click on an image. So far i've been unable to find anything that seems to work with page object.
More specifically i'm looking for a way to handle the download dialogue pop up and to verify that file.exe has begun downloading.
Thank you
You can activate some option when you launch your browser. Here an example I use :
# create the folder location
download_directory = "#{Dir.pwd}/downloads/"
download_directory.gsub!("/", "\\") if Selenium::WebDriver::Platform.windows?
# Create the firefox profile
profile['browser.download.folderList'] = 2
profile['browser.download.dir'] = download_directory
profile['download.prompt_for_download'] = false
profile['browser.helperApps.neverAsk.saveToDisk'] = "application/octet-stream,text/csv,application/pdf"
profile['network.http.use-cache'] = false
# launch FF
#browser = Watir::Browser.new :firefox, profile: profile
Then you don't need to handle the window, but only to check the downloaded file in the folder you define.
For chrome, you can't use a profile, but should use preferences.
# Create the prefs
prefs = {
download: {
prompt_for_download: false,
default_directory: #download_directory
}
}
# Launch chrome
#browser = Watir::Browser.new :chrome, prefs: prefs
And no, I don't find a solution for internet explorer yet.

How can i redirect to another page after the alert is display in XPages

How can I redirect to another page after the alert is displayed and the user clicked on ok?
Below is the code I used
var Admin = doc.getItemValueString("Admin");
var scriptCode = "alert('Email send to the admin: " + Admin + "')";
view.postScript(scriptCode);
When I try to use "context.redirectToHome()" then the alert did not work again. Any idea how I can go about these or any other messagebox function?
Add the redirection to your client side scriptCode with window.location=URL:
var scriptCode = "alert('Email send to the admin: " + Admin + "'); window.location = 'http://www.yourNewPage.com'";
You can calculate the target URL in your code before and add it as a variable (like you do with "Admin").

Resources