Skip to content

Instantly share code, notes, and snippets.

View Adrian-Samuel's full-sized avatar
🎯
Focusing

Adrian Samuel Adrian-Samuel

🎯
Focusing
View GitHub Profile
(async () => {
const domain = window.location.host;
const [RAD, itemID] = window.location.href.match(/\d+/g);
const itemDOMDescription = document.querySelector('.description')
const getItemMatrix = await fetch(`https://${domain}/API/Account/${RAD}/Item/${itemID}.json?load_relations=["ItemAttributes"]`, {
credentials: "same-origin"
});
const itemMatrixData = await getItemMatrix.json();
document.addEventListener('DOMContentLoaded', async () => {
const domain = window.location.host;
const [RAD, orderID] = window.location.href.match(/\d+/g);
const orderTableLines = document.querySelectorAll('body .document:nth-of-type(3) tbody tr > td:nth-child(2)')
document.querySelector("body > table:nth-child(8) > thead > tr > th:nth-child(2)").insertAdjacentHTML('afterend', '<th>Category Name</th>')
const getOrder = await fetch(`https://${domain}/API/Account/${RAD}/DisplayTemplate/Order/${orderID}.json`, {
console.log("lol")
const requestBuilder = async (domain, RAD, endpoint, ID, parameters, isDisplay) => {
let url = `https://${domain}/API/Account/${RAD}`;
if (isDisplay) {
url = url + `DisplayTemplate`
}
if (endpoint == "Label") {
url = `${url}/ItemAs${endpoint}`
} else {
url = `${url}/${endpoint}`
}
// Gets the custom fields for the label template in Lightspeed Retail:
// Function to get custon field values
const requestBuilder = async (domain, RAD, endpoint, ID, parameters, isDisplay) => {
const url = isDisplay
? endpoint == "Label"
?`https://${domain}/API/Account/${RAD}/DisplayTemplate/ItemAs${endpoint}/${ID}.json?${parameters}`
:`https://${domain}/API/Account/${RAD}/DisplayTemplate/${endpoint}/${ID}.json?${parameters}`
:`https://${domain}/API/Account/${RAD}/${endpoint}/${ID}.json?${parameters}`
@Adrian-Samuel
Adrian-Samuel / WorkorderNoteStripper.js
Last active October 4, 2019 16:44
Lightspeed Workorder Note Hider
// Make sure you wrap the script in a script tag
// Insert this after the <h1 class="receiptTypeTitle"> in the Sales template
document.addEventListener("DOMContentLoaded", () => {
const lines_with_notes = document.querySelectorAll('.line_note');
lines_with_notes.forEach(line => {
const line_content = line.innerText;
if (/Work order/gi.test(line_content)) {
const firstLine = line_content.split(/\n/g)[0];
line.innerHTML = line_content.replace(line_content, firstLine);
@Adrian-Samuel
Adrian-Samuel / Montreal_Site_Price Scraper.js
Last active July 16, 2018 10:17
Scraping and Summing Prices on Website with javascript
/* Purpose of this task was to be able to scrape the list of prices onto
the console and sum them. This automates the manual copy and pasting work one would have to do
Website scraped: https://www.mtlblog.com/lifestyle/cost-of-living-montreal
*/
// Target all the content on the page
let it = document.querySelectorAll('#article-text *');
// initialise a string
let words = "";
// cycle through each piece of content on the page
@Adrian-Samuel
Adrian-Samuel / Ajax-Call.js
Created June 5, 2018 16:52
Ajax Call for Lightspeed Receipt
let str = window.location.href;
let new_num = str.replace(/[\s\S]+?([\d]+)\.html[\s\S]+/ig, "$1");
let apiSale = fetch(`https://us.merchantos.com/API/Account/127704/DisplayTemplate/Sale/${new_num}.json`, {
credentials: "same-origin"
}).then((response) => response.json());
let apiCategory = fetch("https://us.merchantos.com/API/Account/127704/Category.json", {
credentials: "same-origin"
}).then((response) => response.json());
let saleData = {
"apiSale": {},
@Adrian-Samuel
Adrian-Samuel / index.pug
Created January 25, 2018 00:31
Seismic Grid
table
tr
td
td
td
td
td
tr
td
td
@Adrian-Samuel
Adrian-Samuel / index.html
Created January 23, 2018 03:10
Pixel Art Maker
<html>
<head>
<title>Pixel Art Maker!</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Monoton">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Lab: Pixel Art Maker</h1>
<h2>Choose Grid Size</h2>