Script creating a redirect warning - google-apps-script

I am working on my first site using google scripts. I have a script embedded that creates a UI and references a Google spreadsheet to link to pages of the same site. Whenever a link is clicked I get an interim page that says:
The previous page is sending you to
https://sites.google.com/site/gchromeat/xxxx.
If you do not want to visit that page, you can return to the previous
page.
Is there a way to get around this?
The behavior can be replicated here: https://sites.google.com/site/gchromeat/home/access

There's no way to go around this, as it seems to be a designed behavior. But there's an issue opened regarding this, you should star it to keep track of updates and kind of vote for it.

I presume you have used an Anchor object in your Google Apps Script. The reason why you get the redirect message is because the anchor object changes the link.
Browsers detect the redirect and ask for user confirmation (browser settings can be changed to avoid this).
Also see issue 1376 - which has been opened for getting rid of some undesirable side effects of this.

Related

Can I deduce HTML POST data from the front end?

please may I have a little help I'm stuck not being able to google for a solution because of very common words.
There is a web page that uses POST to send data to a page on a subdomain when a button is clicked.
I need to recreate a button and send the same information.
My question is: Is it possible just by looking at the page (and the console??) when you click the button, to observer what happens and recreate/implement the same POST method?
Can I say for example: It does this, therefore I need this code to do the same thing?
Or is it not possible to reverse engineer? Will I have to seek help form the web page developer (not really an option in this case).
It is perfectly possible to inspect the request and reverse engineer this. You can use tools like the developer console in your Chrome/Edge browser (press F12), and tools like Postman to simulate requests. Also inspect the form and eventual javascript events attached to the button.

Is there any workaround for uploading picture into Google Form responses without having to be signed in to a Google account?

I was wondering if there are any workaround for responding to a form with a picture but without the respondent having to sign in into their google account? Maybe like a a script or something to trick the form to think that every time a respond is sent, it came from the owner.
I'm thinking of having the form to be filled in from an app built on AI2 instead of directly from the actual form as well.
If anyone have any ideas whether this is achievable or not, do respond.
I'm still working on this too, but in my opinion it's a two-parter.
First, you upload the file to a separate folder; then, you link the file URL back to the form as a short answer. Separating the two allows you to ignore the pesky "you must have a Google Account to do this" because if you set up your WebApp properly it does look like it's coming from the owner.
This will help you upload the file: https://sites.google.com/view/metricrat-ai2/guides/upload-any-file-to-google-drive-with-ai2
I would suggest downloading the example and adding it to your projects and copying over via your backpack, though. For some reason recreating the code from the pictures he's got up doesn't work for me.
The second half is where it gets tricky. I'm wondering if it's possible to manipulate the final steps in the GAS to return the content URL, but haven't totally wrapped my brain around it yet.

Google Tag Manager fires tags in preview/debug, but not on the live site

I've used GTM numerous times to fire LD-JSON business schema via a custom-html tag with Tag Manager. This time however, I'm running into issues.
The tags fire in the debug/preview mode of GTM, but when I publish it they are not found on the live site. Tag assistant shows no issues with the installation; I should add the custom HTML doesn't appear on the debug/preview, but the tag does fire (per the debugger).
The site in question uses WP-engine, but I've been told that's not likely the issue. If anyone can point me in a direction that would be great.
I posted on the product forums for google: https://productforums.google.com/forum/?utm_medium=email&utm_source=footer#!msg/tag-manager/RfxZcqbWrSg/wAWzn98TCwAJ
The issue here was GTM was using the 'document.write' feature for the custom HTML container (which housed the LD-JSON Schema). Removing that feature populated the site where Google could read the schema.
Props to Simo for being a 'sweet dude' for pointing this out.
I also faced one similar issue, and for me it was how google tag manager file was served from the app.
It was being served as
https://www.googletagmanager.com/gtag/.js?id=yourGtmId
instead of
https://www.googletagmanager.com/gtm.js?id=yourGtmId
Although in the preview mode, the correct file was being served somehow!
Just want to mention that I was having this problem also, and being new to adding custom HTML / JavaScript to my website through Google Tag Manager, I was completely oblivious to the fact that you must click the submit button in the top right of one of the main views (Overview, Tags, Triggers, etc.) in order to publish your changes. I was thinking that the save button within the trigger or tag was all that was needed.(Be sure that you are not forgetting this simple step!).

How to embed Google Compose Mail window in to Google Sheet Form?

I won't bore everyone reading this post with the entire background story of why I need to do this. However, I am looking to load the Google Compose Mail page in the HTML form loaded inside a Google Sheet I have created.
I know the link for the Compose email is https://mail.google.com/mail/u/0/?view=cm&fs=1&tf=1&to=TO&su=SUBJECT&body=BODY
But I don't know if it is possible to have this link loaded as a view in the HTML service Form.
Does anyone know if this is possible and if so, how to do it?
I could always have a button to load the link in a separate tab... but I would like to have this all kept on screen to be more "professional" looking.
I was looking for an option to add an iframe or free code, but option exists. I recommend inserting a form if you are looking for a way to get data from users.
Its under "Insert", then "Form..."
Good Luck

Window.postMessage - Two pages, same URL

I'm using
window.postMessage({message: "Hello !"}, url);
to send a message from a Chrome Extension (i don't know if this is relevant) to a specific page in a window with multiples opened pages. I noticed that sometimes i have TWO pages with the same URL.
I have a simple question:
How can i be sure to which page is postMessage sending the message ?
I want to send the message to only one tab. Can i use anything else apart from the url to identify the it?
Thanks in advance !
Considering that you said you can modify the remote website's code, and I don't see how to fix the postMessage solution, here are a couple of alternatives. I would love to know if there is a way to fix the postMessage approach, as it is the recommended one from the docs!
First off, you will need to coordinate your scripts from a central background page, which can keep track of open tabs.
Custom DOM events
This is an old recommendation from Chrome docs, that was replaced with window.postMessage example. It is described here (disregard the old chrome.extension.connect API) and consists of firing a custom event in shared DOM.
So, a sample architecture would be a background page deciding which tab to post message to, and sending that tab a message via chrome.tabs.sendMessage, to which your content script listens with chrome.runtime.onMessage. The tab's content script can then communicate with the page using the above custom event technique.
One possible approach to keeping tack of tabs: have the tabs permission to be able to enumerate all open tabs with the chrome.tabs API. Your background page can then decide which tab to message based on URL.
Another possible approach, to eliminate need for the scary tabs permission, is to have your content scripts report to the background page with chrome.runtime.connect as soon as they are initialized. The background page then can keep track of all active instances of your script and therefore decide which tab to message.
Webpage connecting to your extension
This is a "modern" way of doing communication with one exact extension.
It is described in the Chrome docs here. You can define your extension as externally connectable from your webpage, and your webpage initiates a port connection with your background script.
Then, as above, you can track live ports and use them for communication, cutting out the content script middleman.