Skip to content

Instantly share code, notes, and snippets.

@Micorksen
Last active April 29, 2023 11:22
Show Gist options
  • Save Micorksen/d74d15b0347c96832f71d0afa4518c05 to your computer and use it in GitHub Desktop.
Save Micorksen/d74d15b0347c96832f71d0afa4518c05 to your computer and use it in GitHub Desktop.
Get a pre-filled link for Google Forms.
// ==UserScript==
// @name Forms Filler
// @namespace https://micorksen.eu
// @version 1.0
// @description Get a pre-filled link for Google Forms.
// @author Micorksen
// @match https://docs.google.com/forms/*
// @icon https://gstatic.com/images/branding/product/2x/forms_2020q4_48dp.png
// @require https://code.jquery.com/jquery-3.6.3.slim.min.js
// @grant GM_setClipboard
// ==/UserScript==
'use strict';
$(function () {
$('div.lRwqcd').append('<div role="button" class="uArJ5e UQuaGc Y5sE8d VkkpIf QvWxOd" jscontroller="VXdfxd" jsaction="click:cOuCgd; mousedown:UX7yZ; mouseup:lbsD7e; mouseenter:tfO1Yc; mouseleave:JywGue;touchstart:p6p2H; touchmove:FwuNnf; touchend:yfqBxc(preventMouseEvents=true|preventDefault=true); touchcancel:JMtRjd;focus:AHmuwe; blur:O22p3e; contextmenu:mg9Pef;" jsshadow="" jsname="M2UYVd" tabindex="0" id="forms-filler"><div class="Fvio9d MbhUzd" jsname="ksKsZd"></div><div class="e19J0b CeoRYc"></div><span jsslot="" class="l4V7wb Fxmcue"><span class="NPEfkd RveJvd snByac">Copy pre-filled link</span></span></div>')
$('#forms-filler').on('click', function () {
let v = [],
u = `${window.location.origin}${window.location.pathname}?`
$(this)
.addClass('M9Bg4d')
.addClass('qs41qe')
setTimeout(function () {
$('#forms-filler')
.removeClass('M9Bg4d')
.removeClass('qs41qe')
}, 250)
$('input[type="hidden"][name^="entry."]').each(function () {
const e = $(this)
v.push(`${e.attr('name')}=${encodeURIComponent(e.attr('value'))}`)
})
u += v.join('&')
GM_setClipboard(u, 'text')
alert('Copied link to the clipboard.')
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment