i was wondering if there is a possibility to distribute my Custom Script to all the sheets in my workspace. I came upon different ways with libraries or Add-ons, but they all lack some points i want to accomplish.
I want it to be private only for my Google Account
I need it to run the onOpen(e) Trigger for every File on my Sheets Account
(So i can add a custom menu to all my Files)
I also need to set a time Trigger for each File so my main() Function runs every night (right now i always create a new trigger when i rerun my main Function)
So far i can use the Library Option and create a new Script for all my Files and call my Main Function out of that Library. This Workaround does not include an onOpen Trigger event. When i use the Ability of run->test as addon and manually add all new Files (which come up every new month) i also lack the possibility of trigger functions.
If you have Solution Ideas I'd be very happy.
BR NJ
An Add-on can be published privately. Private Add-ons
A Library is private by default - The only way that someone outside of your account can use your script as a library, is to set the file sharing to allow them to use it. Gaining access to a library
A Library can not run a simple trigger, but an Add-on can. The reserved function name onOpen() can't be triggered by a library. See Table - Resource Scoping
An Add-on can run the onOpen() function
An Add-on can create an add-on menu.
An Add-on can create one time-based trigger for each document it is installed in. Quote: "Each add-on can only have one trigger of each type, per user, per document" Add-on Restrictions
If you want to do something like overwrite an Apps Script file, that can be done with the Apps Script API. Even script projects that are bound to a document (Sheets, Forms, Docs) can be overwritten with the Apps Script API.
StackOverflow answer - Update an Apps Script file using Apps Script
You can also update the manifest file of an Apps Script file using the Apps Script API, and therefore, programmatically add a library, and the library version to an existing Apps Script File.
Related
I´m a bit confused with Google Tag Manager and gtag.js. I have read a lot about it, but It´s not 100% clear to me what to use in my case.
Historically, we have been using gtag.js in our AngularJS webapp. We also used the library angularytics to track Google Ads conversions of purchases providing dynamically prices and leads directly from our website.
We have migrated to GTM to provide third party libraries from the GTM interface. This means that we have commented/removed gtag.js. Now, we track page analytics from GTM. However, obviously, our angularytics calls to Google Ads conversion tracking using gtag.js has stopped working.
At this poing I´m very confused with some questions:
I have read that I can add Google ads conversion tracking using GTM setting up conversions one by one. But, is it possible to set the price of each product which is totally dynamic? Or this case should I use gtag?
Does GTM provide a library to replace gtag functions? From the SEO optimazation point of view, I think would be interesting to avoid loading two libraries gtm and gtag.
Is there any problem that both libraries live together?
Well, you can think of GTM as a service where you can dynamically change the included tags in a website without direct access to the production source code. This is for example widely used for marketing agencies whose clients won't give away access to their servers. But it doesn't really have anything to do with Google Analytics at all as you can insert tags from any service provider (Social pixels, Intercom-like services...)
If you use Google Tag Manager to handle those tags you should remove the script call from your code. Otherwise it will be invoked twice
I'm working on my first google chrome extension. One of the things that concerns me is that I may need to perform regular updates since the extension is quite intricate.
DETAILS:
-The extension uses content scripts to manipulate the DOM. The content scripts manipulate the DOM by injecting web components.
- My extension relies on some external dependencies such as underscore, backbone and jQuery
In brief, I've heard about about the Web Store API but I am interesting in any thoughts about this topic.
How does one typically handle updates for external dependencies such as jQuery, etc?
The correct way is to include those external depencencies as part of your code and not link to the cdn or external repository. This is also explained in the official docs.
If for some reason you must update the library just publish a new version of the extension taking into account that it normally takes a day until chrome upgrades your users.
There are a few exceptions. For example google recommends that their google analytics library be linked and injected. Its slower and less efficient but some libraries ask you to do it.
I developed a Shopify application that i install on Shopify Store and i want my application to add a javascript snippet in all the store pages. For this I want my application to modify the current theme, by using Shopify API, and add the javascript snippet to that theme.
I know of several ways to do it but they have several disadvantage:
Add a Shopify Asset/Snippet - The store owner has to manually modify the store's theme to link to the asset/snippet.
Add a script tag - I want my javascript to be embedded and not to be downloaded from a different source. A different source means longer page loads and i do not want my site to extend the page load.
Add an application proxy - This can also extend the loading time.
Can you suggest on what is the correct way to do it?
Add a script tag and be done with it. No other pattern offers up the same customer experience. When they install your App, your script is available. When they uninstall your App, their theme reverts nicely. Worrying about the load times of your asset is not worth it if you have done your job, and minimized your code and provided a fast CDN address for it.
In 2022, you get Theme App Extensions for OS 2.0. Do that!! Best way to add JS to a theme/store.
Are you using the embedded apps SDK? I'm pretty sure they have some option that makes this easier, like you can create a "sidebar" on every page and position it wherever you want (hidden if necessary).
Answering you question: the good way is using ScriptTag. Consider this article on this: https://docs.shopify.com/api/unlinked/using-javascript-responsibly
Still if you need to add code snippet as an asset, I want to point out that it's not necessary the customer must manually update the theme. As far as I know, you can add your snippet as an asset and then update another -- theme liquid template.
https://docs.shopify.com/api/asset#update
For the reasons described in an article I've provided above, you should not do that.
Call a standalone script by a SCRIPT in a Google Docs (Document)
The aim would be to create a few sort of "Add-on Custom" which is only my documents created with Google Docs Prototype containing a script with a few command line calling a standalone script .
Hi,
Right now, only container-bounded scripts can use "advanced" interactions (create menus, prompts, etc) on a container Spreadsheet, Docs or Forms.
I'd like this ability on a standalone script!
The primary use-case for this is to allow developing and maintain a single script that is used in multiple documents. Because right now, if we have a script that does some nice things on a Spreadsheet (or any other container) we face two major problems.
First, it's very difficult to distribute your script. It often involves multiple steps a end-user have difficulty to do, or have them create the document from a template you setup previously.
And the second problem is maintaining/updating a distributed script, because we have one independent copy on each file. And even if you have access to all files, updating is a nightmare. Even if you use libraries and just need to get in to each one to update the library number (since the library development mode only works if all the users have edit permissions on your library, which is crazy).
If we could have a single standalone script that we, the developers, could control the update/deployment version for all our users/documents, just like we do for web-apps, it would be great!
Lolo
Its called apps script libraries. Check the docs for more detail.
https://developers.google.com/apps-script/guide_libraries
Is it possible for the javascript you write for a XUL component to interact with the javascript defined in a webpage?
Eg, if a particular webpage has a dooSomethingNeat() function, can I have a button defined in a XUL overlay execute that function, or does it live in another namespace?
Put another way: if I'm looking to enhance the functionality of a website via my own code, does it make more sense to write a Firefox extension or use something like greasemonkey?
See my answer to another question here.
The webpage code does live in a 'namespace' separate from the scopes the browser code executes in.
It doesn't mean you can't access it from an extension, though.
On the other hand, running a function in a content page is not very easy to do securely at this moment.
Greasemonkey scripts (and ubiquity scripts, which can also interact with web pages) are somewhat easier to develop than extensions, and Greasemonkey already implements the required security precautions to allow you interact with web pages safely.
If you want others to use your script, packaging it as a standalone extension lowers the barrier to entry (on the other case, existing GM users may prefer simpler GM scripts to a separate extension).
So if you can implement what you need to do with a GM script or an ubiquity script, I'd say go with it. At least you can start with it, then convert to an extension when you find something you can't do with GM.
If you need features not supported by Greasemonkey or if you just want to try creating an extension, it is also a viable option.
There is a Greasemonkey-to-firefox-extension "compiler" available, but it isn't up-to-date with the latest GM changes.
However, it does have the basic GM framework for page interaction and security all wrapped up as a standalone extension, ready for you to modify and extend.
Wether to use standalone extension or GM-script depends upon who will be installing this. Will the user-base be willing to install GreaseMonkey, THEN the script? Or is the extension alone enough of an installation barrier?
The GM license does allow for repackaging it with pre-set scripts, I believe, but I can't find back citations for this, at the moment.