Skip to content

Instantly share code, notes, and snippets.

View sambessey's full-sized avatar

Sam Bessey sambessey

View GitHub Profile
const http = require('http');
const server = http.createServer((req, res) => {
// Print request headers
console.log('Headers:');
console.log(req.headers);
// Print request body
let body = '';
req.on('data', chunk => {
{"v":1,"data":[{"id":"d1","matchUrl":"https://acme.amperity.com/*","rules":[{"type":"headerRule","match":"https://*","requestRules":"","responseRules":"set Access-Control-Allow-Origin: *;remove Content-Security-Policy;remove X-Content-Security-Policy","on":true}],"on":true}]}
// ==UserScript==
// @name Custom Segments Builder for Acme
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://acme.amperity.com/?th=44yHf
// @icon https://www.google.com/s2/favicons?sz=64&domain=amperity.com
// @grant none
// ==/UserScript==
const puppeteer = require('puppeteer');
var isBot = {
navigate:{
toHome: async function(page){
await page.goto('https://www.accenturepets.com/');
},
toRandomItem: async function(itemId,page){
await isBot.do.clickThis(page,{
//ele:`#maincontent > div.container.home-product-tiles.homepage > div.hp-product-grid > div > div > div > div:nth-child(${itemId}) > div > div > div.image-container > a > img`,
ele:`#maincontent > div.container.home-product-tiles.homepage > section > div > article:nth-child(${itemId}) > a > img`,
@sambessey
sambessey / accenturepets.js
Created March 31, 2022 23:00
AccenturePets Javascript
<script type="text/javascript" src="//cdn.evgnet.com/beacon/partneraccentureaus/accenturepets/scripts/evergage.min.js"></script>
@sambessey
sambessey / aster-bell-sitemap.js
Last active March 7, 2022 05:57
Sitemap for Aster & Bell (Fictional retailer)
var evgHelpers = {
brightLog: function(m, c='#0095da') {
console.log(`%cEvergage::-> ${m}`, `color: white;background-color:${c};font-size:10px`)
},
getDataLayer: async function() {
/* This function waits for the datalayer to become accessible to the browser, then it returns
a resolved promise that contains the correct DL object. It tries 10 times then gives up if not found.*/
return await new Promise((resolve, reject) => {
let c=0
let int = setInterval(_=>{
@sambessey
sambessey / is-ss-demo
Last active March 6, 2022 23:09
Interaction Studio Authenticated Server Side Campaign Demo (Using TamperMonkey)
// ==UserScript==
// @name Example SS Integration
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Example Server Side Integration in IS
// @author Sam Bessey
// @match https://ecomm-is.vercel.app/*
// @grant GM.xmlHttpRequest
// ==/UserScript==
// ==UserScript==
// @name User Metrics in EDP
// @namespace http://tampermonkey.net/
// @version 0.1
// @description See Name
// @author Sam Bessey
// @match https://cust100357a.cheetahedp.com/console/*
// @require https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js
// @resource CHART_JS_CSS https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.css
// @resource CARD_CSS https://sambessey-public.s3.eu-west-2.amazonaws.com/card.css
//Client Side async fetch for an IS Campaign - Demo Example
// Sam Bessey (sbessey@salesforce.com)
let endpoint = 'https://sbessey1084858.germany-2.evergage.com/sscreceiver?_ak=sbessey1084858&_ds=engage&userId=2a1547b87827e1e8&_anon=false&action=ServerSideReq'
async function getISData() {
let response = await fetch(endpoint)
let data = await response.json()
return data
}
getISData().then(data=>{
var evgHelpers = {
cleanString: function(input) {
console.log(input,'<INPUT---------------------')
console.log(input(),'<---------------------')
console.log(input().replace(/[^\x20-\x7E]/g, ''))
console.log(input().replace(/[^\x20-\x7E]/g, '').length)
return input().replace(/[^\x20-\x7E]/g, '')
},
getAuthour: function() {
let a = "#globalWrapper > main > div:nth-child(3) > div > article > div.content-groupset.pos-beta > div > div.story-text.has-sidebar > div.story-intro.format-s > div > footer > p:nth-child(1) > span > span:nth-child(1) > a"