Skip to content

Instantly share code, notes, and snippets.

View franzenzenhofer's full-sized avatar

Franz Enzenhofer franzenzenhofer

  • http://www.fullstackoptimization.com/
  • Vienna, Austria
View GitHub Profile
javascript:(function() {
try {
// Check if window.getSelection() is available
var selection = window.getSelection ? window.getSelection().toString().trim() : '';
// Double check to ensure we have access to the current URL
var currentUrl = window.location.href ? window.location.href : 'URL unavailable';
// Construct the message based on the selection or lack thereof
var message = selection || `Fetch content from ${currentUrl} for context. Please wait for further instructions.`;
var baseMessage = `I copied this content:\n\n>>>\n"${message}"\n>>>\n\nFrom this URL: ${currentUrl}\nFetch this URL for more context.\n\nPlease wait for further instructions.`;
@franzenzenhofer
franzenzenhofer / createLineChartWithQuartiles(sheetName)
Created June 20, 2023 11:34
Line Chart Visualisation of Google Search Console Data in App Script
function runAnalyses() {
createLineChartWithQuartiles('Queries');
createLineChartWithQuartiles('Pages');
createLineChartWithQuartiles('Countries');
createLineChartWithQuartiles('Devices');
createLineChartWithQuartiles('Dates');
}
function createLineChartWithQuartiles(sheetName) {
var sheet = SpreadsheetApp.getActive().getSheetByName(sheetName);
const axios = require('axios');
const cheerio = require('cheerio');
const argv = require('yargs').argv;
const sleep = require('util').promisify(setTimeout);
const start_url = argv._[0] || '';
const delay = argv.s || 1;
const headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
@franzenzenhofer
franzenzenhofer / count clicks by pagetype GSC
Created June 1, 2023 13:49
count clicks by pagetype GSC
function analyzeURLs() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const data = sheet.getDataRange().getValues();
deleteSheets(['Page Type Analysis', 'Language Namespace Analysis', 'Parameters Analysis', 'Copied & Analyzed']);
// Create a copy of the original sheet
const newSheet = sheet.copyTo(SpreadsheetApp.getActiveSpreadsheet());
newSheet.setName('Copied & Analyzed');
@franzenzenhofer
franzenzenhofer / GSC brand unbrand script
Created June 1, 2023 08:49
GSC brand unbrand script
function calculateAndCreatePieChart() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getSheetByName('Queries');
var chartSheetName = 'brand';
var brandstring = "radar";
// Remove old chart sheet if exists
var oldChartSheet = spreadsheet.getSheetByName(chartSheetName);
if (oldChartSheet) spreadsheet.deleteSheet(oldChartSheet);
@franzenzenhofer
franzenzenhofer / GSC Dates Average Charts
Last active May 31, 2023 16:31
GSC Dates Average Charts
// Global spreadsheet object
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
//console.log(spreadsheet);
function main() {
console.log("main");
generateLineCharts();
}
// Function to delete multiple sheets
@franzenzenhofer
franzenzenhofer / GSC Devices Bar Chart
Created May 31, 2023 12:26
GSC Devices Bar Chart
function generateCharts() {
// Access the sheet
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Devices');
// Sort Column A
sheet.getRange('A2:E4').sort(1);
// Get the range for your data
var dataRange = sheet.getRange('A1:E4');
@franzenzenhofer
franzenzenhofer / Google-Apps-Script-URL-Analysis
Last active May 31, 2023 16:30
currently for TR.client
function analyzeURLs() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const data = sheet.getDataRange().getValues();
deleteSheets(['Page Type Analysis', 'Language Namespace Analysis', 'Parameters Analysis', 'Copied & Analyzed']);
// Create a copy of the original sheet
const newSheet = sheet.copyTo(SpreadsheetApp.getActiveSpreadsheet());
newSheet.setName('Copied & Analyzed');
@franzenzenhofer
franzenzenhofer / Google-Apps-Script-Monthly-Traffic-Analysis
Created May 23, 2023 21:25
This Google Apps Script is designed to analyze and visualize web traffic data from Google Sheets. It generates a line chart that displays the total and median clicks for each month, discarding any incomplete months. The chart also includes a trendline to help identify patterns or trends over time. This script is especially useful for SEO analyst…
function createChart() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// Get the last row with content
var lastRow = sheet.getLastRow();
// Get data range
var dataRange = sheet.getRange('A2:B' + lastRow);
var data = dataRange.getValues();
{
"exportFormatVersion": 2,
"exportTime": "2020-10-06 15:31:33",
"containerVersion": {
"path": "accounts/6000775609/containers/32949204/versions/0",
"accountId": "6000775609",
"containerId": "32949204",
"containerVersionId": "0",
"container": {
"path": "accounts/6000775609/containers/32949204",