On-demand scraping only when button clicked

Welcome to the Make community!

Could be easily made with a userscript. The userscript can inject a button onto any page to send the URL of the current page to your Custom Webhook.

To use userscripts, you’ll need to install a userscript manager extension. I personally use Tampermonkey, which you can head there and install your respective web browser’s version.

Then, click on the Tampermonkey icon and select “Create a new script”
Screenshot_2024-01-09_100145

Paste this in the script editor, change webhookUrl to your Custom Webhook URL, and press save (or CTRL-S)

// ==UserScript==
// @name         Make Custom Webhook Button
// @version      0.1
// @description  This adds a button onto all web pages, when clicked, sends the current page to a Custom Webhook trigger on Make
// @author       @samliew
// @include      *
// @connect      *
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function() {
  'use strict';

  // Your Custom Webhook URL
  const webhookUrl = 'https://hook.us1.make.com/abcdefghijklmnopqrstuvwxyz123456';

  // Create button
  const btn = document.createElement('button');
  btn.textContent = 'Send to Make';
  btn.style.position = 'fixed';
  btn.style.bottom = '0';
  btn.style.right = '0';
  btn.style.zIndex = '999999';
  btn.style.padding = '0.5em 1.2em';
  btn.style.fontSize = '1rem';

  // When button is clicked
  btn.addEventListener('click', function() {

    // Get current page URL
    const url = window.location.href;

    // Disable button
    btn.disabled = true;

    // Send GET request to Custom Webhook trigger
    GM_xmlhttpRequest({
      method: 'GET',
      url: webhookUrl + '?url=' + encodeURIComponent(url),
      onload: function(response) {
        console.log(response);

        if (response.status !== 200) {
          console.error(response.statusText || response.responseText);
          btn.textContent = 'Error';
          return;
        }

        // Remove button after 5 seconds
        btn.textContent = 'Sent';
        setTimeout(() => btn.remove(), 5000);
      }
    });
  });

  // Add button to page
  document.body.appendChild(btn);
})();

Now all pages will have a button on the bottom right that you can click.
When clicked, if the button says “Error”, it means your webhook is invalid/cannot be found.
Screenshot_2024-01-09_110121

Then, you can pass the URL parameter variable into a scraping module:

2 Likes