Skip to content

Instantly share code, notes, and snippets.

View hnestmann's full-sized avatar

Holger Nestmann hnestmann

  • Salesforce
  • Jena
View GitHub Profile
/** source https://github.com/GoogleChromeLabs/puppeteer-examples/blob/master/side-by-side-pageload.js
* Thanks Google
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
**/
const puppeteer = require('puppeteer');
const DEFAULT_VIEWPORT = {width: 1000, height: 800, deviceScaleFactor: 2};
function fauxcapi() {
var HTTPClient = require('dw/net/HTTPClient');
var path = decodeURIComponent(request.httpParameterMap.path.stringValue);
var httpClient : HTTPClient = new HTTPClient();
httpClient.open('GET', 'https://' + request.httpHost + '/' + path);
httpClient.setTimeout(5000);
httpClient.send();
response.setContentType('application/json');
var expiryTime = new Date(Date.now());
const fs = require('fs');
var xmlParser = require('xml2js').parseString;
const startPath = process.argv[2];
const translate = require('@k3rn31p4nic/google-translate-api');
var categories = [];
function handleCategory(index, callback) {
if (index > categories.length) {
return;
}
/**
* parses the query string for custom expand parameter
* @returns {Object} a parameter object containing paging information based on request params or defauls
*/
function parseQueryString() {
var params = null;
var queryString = request.httpQueryString;
if (queryString.indexOf('c_expand=true') > -1) {
params = {};
const { appendFile } = require("fs");
const fetch = require("node-fetch");
const fs = require('fs');
const params = JSON.parse(fs.readFileSync('./config.json'));
/* Example
{
"accountManager": {
"scope": "SALESFORCE_COMMERCE_API:xxxx_xxx sfcc.yy",
"clientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
@hnestmann
hnestmann / add-to-cart.js
Created December 2, 2020 07:52
add-to-cart.js
const { appendFile } = require("fs");
const fetch = require("node-fetch");
const fs = require('fs');
const params = JSON.parse(fs.readFileSync('./config.json'));
/* Example
{
"accountManager": {
"scope": "SALESFORCE_COMMERCE_API:xxxx_xxx sfcc.yy",
"clientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
<?xml version="1.0" encoding="UTF-8"?>
<shipping xmlns="http://www.demandware.com/xml/impex/shipping/2007-03-31">
<shipping-method method-id="standardDHL_DE" default="false">
<display-name xml:lang="x-default">DHL Standard</display-name>
<online-flag>true</online-flag>
<price-table>
<amount order-value="0">0.99</amount>
</price-table>
<excluded-addresses>
<included-addresses>
var customerPromotions = dw.campaign.PromotionMgr.getActiveCustomerPromotions();
/**
* Converts a product into a extended object
*/
function createExtendedProduct(productId) {
var staticCache = dw.system.CacheMgr.getCache('ProductExtendStatic');
var product = dw.catalog.ProductMgr.getProduct(productId);
if (!product) {
return;
// ==UserScript==
// @name Set Parcel Shop Id
// @version 1
// @grant none
// ==/UserScript==
if (window.location.href.includes('https://production-realm-customer.demandware.net/on/demandware.store/Sites-Site/')) {
function waitForElement(selector) {
return new Promise(function (resolve, reject) {
/**
* Input: Line separated SKUs (e.g grepped from catalog export), inventory export
* Output: inventory import of all 0 item items
*
* Original use case: customer shows Back-in-Stock only if item has zero item inventory, however production cleaned 0 to null removing bis
*/
const fs = require('fs');
var readlines = require('n-readlines')