monitor.js 901 B

123456789101112131415161718192021222324
  1. // Specify the IFTTT event name and Webhooks key before enabling this script through "monitor" property in _config.yml
  2. (async function () {
  3. const EVENT_NAME = '';
  4. const WEBHOOKS_KEY = '';
  5. try {
  6. const { ip } = await fetch('https://api.ipify.org?format=json').then(res => res.json());
  7. const { href: url } = window.location;
  8. const screenDimensions = `${window.screen.width} x ${window.screen.height}`;
  9. const { referrer } = document;
  10. const { userAgent } = navigator;
  11. const strToSend = encodeURIComponent([
  12. `IP: ${ip}`,
  13. `URL: ${url}`,
  14. `Screen Dimensions: ${screenDimensions}`,
  15. `Referrer: ${referrer}`,
  16. `User Agent: ${userAgent}`
  17. ].join('<br>'));
  18. await fetch(`https://maker.ifttt.com/trigger/${EVENT_NAME}/with/key/${WEBHOOKS_KEY}?value1=${strToSend}`, {
  19. method: 'GET'
  20. });
  21. } catch (error) {
  22. console.error(error);
  23. }
  24. })();