Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom Google Sheets Function
/** Brings two columns of strings together.
*
* @param {string} First string.
* @param {string} Second string.
* @return both strings together.
* @customfunction
**/
function COMBINESTRINGS(first, second) {
return first + ' ' + second;
}
/** Brings two columns of strings together.
*
* @param {string} First string.
* @param {string} Second string.
* @return both strings together.
* @customfunction
**/
function COMBINESTRINGS(first, second) {
return first + ' ' + second;
}
/**
* Multiplies the input value by 2.
*
* @param {number} input The value or range of cells to multiply.
* @return The input multiplied by 2.
* @customfunction
*/
function DOUBLE(input) {
if (input.map) {
return input.map(DOUBLE);
} else {
return input * 2;
}
}
function LogLink(input){
return Logger.log(input);
}
function test() {
var url = getWebLinks('https://developers.google.com/apps-script/guides/sheets/functions#optimization');
url.map(LogLink);
}
/**
* Gets all links from web page
*
* @param {string} input The website url
* @return The links in a page
* @customfunction
*/
function getWebLinks(url) {
var response = UrlFetchApp.fetch(url);
var content = response.getContentText();
var linkUrls = content.match(/href="(.*?)"/g).toString();
var arrayLinks = linkUrls.split(',');
return arrayLinks;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment