Updated all bookmarklets to just be functions and we can use utils/bookmarkletMaker.js to generate the bookmarklets in the console for now.

This commit is contained in:
Greg Jacobs
2024-06-12 13:04:47 -04:00
parent 3f25aef4f2
commit e2c5035011
26 changed files with 587 additions and 380 deletions

11
.gitignore vendored
View File

@@ -1,3 +1,12 @@
# The usual suspects in frontend dev
package-lock.json
node_modules/
codingstandards.txt
# References used by copilot
references/
#Static files created by apps
output/
# Environment variables
.env

View File

@@ -1,29 +1,47 @@
# Gregs Memory Palace
This project contains several files that perform various tasks. Here's a brief overview of each file:
This project contains several files that perform various tasks to make my life easier. This README is maintained by one of the functions in here and ran on a pre-commit hook. Any new files added in utils make sure there are comments so this file can be as useful as possible.
# File Summary
## [apiResponseChecker.js](src\utils\apiResponseChecker.js)
This file contains a script that fetches data from an API and writes it to a file.
The script makes multiple API calls at regular intervals for a specified duration.
The fetched data is appended to separate files based on the data center, user tier, and security symbol.
The script uses Axios for making HTTP requests and the fs module for file operations.
The script exports a function fetchAndWriteApiData that takes an object with the following properties:
- url: The URL of the API endpoint to fetch data from.
- headers: An object containing the headers to be sent with the request.
- dataCenter: The data center to which the API request should be made.
- userTier: The user tier for which the API request should be made.
- xid: The xid of the security for which the API request should be made.
If user does not provide any input, it opens the default DAG Tasks page in a new tab.
- symbol: The symbol of the security for which the API request should be made.
The script also schedules the API calls to be made every 2 minutes for a duration of 4 hours.
The start time and stop time are logged to the console.
## [bookmarkletMaker.js](src\utils\bookmarkletMaker.js)
This script generates a bookmarklet from a JavaScript file.
It reads the JavaScript file, removes any multiline comments, and creates a bookmarklet string.
The bookmarklet can then be used to execute the JavaScript code in a browser.
Use this to generate a bookmarklet from a JavaScript file in the utils/bookmarklets directory.
@param {string} filePath - The path to the JavaScript file.
@returns {string} The generated bookmarklet.
## [apiDocs.js](src\utils\bookmarklets\apiDocs.js)
2. Decodes the string using decodeURIComponent.
Opens the API documentation for a given project API.
Requires the use of utils/bookmarkletMaker.js to generate the bookmarklet.
@param {string} projectAPI - The project API to open the documentation for.
## [jira.js](src\utils\bookmarklets\jira.js)
## [dag.js](src\utils\bookmarklets\dag.js)
Opens the DAG Task details page(s) based on user input.
If user provides a comma-separated list of DAG Task numbers, it opens each task's details page in a new tab.
@@ -35,20 +53,10 @@ It then triggers events to simulate user input and key presses to add the securi
This JavaScript function takes a string, decodes it using decodeURIComponent,
alerts the decoded string, and copies the result to the clipboard.
The function works as follows:
1. Takes a string as input.
2. Decodes the string using decodeURIComponent.
3. Alerts the decoded string.
4. Copies the decoded string to the clipboard.
and then opens a new browser tab for each corresponding Jira page for those MOIDs.
The function works as follows:
1. Prompts the user to enter MOID numbers separated by commas. The entered values are stored in the `answers` array.
2. Sets a default URL to the Jira dashboard.
3. Checks if the user entered any values in the prompt.
4. If the user entered values, changes the URL to point to the specific Jira page for each entered MOID number.
5. Opens each URL in a new browser tab and brings focus to the last opened tab.
Note: This function is wrapped in a self-invoking function `(function() {...})();` which means it will automatically execute as soon as it is defined.
## [rbc-di-featureflags.js](src\utils\bookmarklets\rbc-di-featureflags.js)

View File

@@ -3,12 +3,14 @@
"version": "0.0.1",
"description": "This project contains several files that perform various tasks. Here's a brief overview of each file:",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint src --ext .js",
"lint:fix": "eslint src --ext .js --fix",
"format": "prettier src --write --ignore-unknown",
"readme": "node updateReadme.js"
"readme": "node src/utils/git/updateReadme.js",
"bookmark": "node src/utils/bookmarkletMaker.js"
},
"repository": {
"type": "git",
@@ -21,5 +23,10 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.3.0"
},
"dependencies": {
"axios": "^1.7.2",
"dotenv": "^16.4.5",
"json": "^11.0.0"
}
}

24
src/ideas/RBCDict.txt Normal file
View File

@@ -0,0 +1,24 @@
SGID=6756377f6537943100df345f380035003301
language=ENGLISH
system=NETA
7AServer=N600LD
rbPath=https://www1.steroyalbank.com/cgi-bin/rbaccess/rbunxcgi
siteNavCss=https://www1.steroyalbank.com/N600/css/rbcSiteNav_1024Mega.css
siteNavJs=https%3a%2f%2fwww1.steroyalbank.com%2fcgi-bin%2frbaccess%2frbunxcgi%3fF22%3d4WN600S%267ASERVER%3dN601LD%26LANGUAGE%3dENGLISH%267ASCRIPT%3d%2fWebUI%2fNavigation%2fHeaderFooter
titleHeader=Navigation Header
titleMenu=Menu
titleFooter=Footer
requestTime=739042.12:03:04.3789018
refId=sucduu%252fQIQBuLwttXjWgvw%253d%253d
showlevel2=no
NETA=1
DSOL=1
WM=1
IB=0
HOME=0
rollover=1
xtid=RBC:6756377f6537943100df345f380035003301
xbrand=NETA
LOGICALSESSID=iHpJZiDwq91hZlQwAAD4HwAAbXYFAA__
RBCAPI=STE_ENV2
HSBCStatus=1

View File

@@ -1 +1,7 @@
- Checking network tab for certain calls and showing their data
- C:\Projects\memorypalace\src\utils\importBookmarkMaker.js
Postman script to run every x mins to return data and store data in two sep files for ctc and ptc
VS Code Thunderclient

15
src/ideas/split.js Normal file
View File

@@ -0,0 +1,15 @@
const fs = require('fs');
const filePath = '/Projects/memorypalace/src/ideas/RBCDict.txt';
// Read the contents of the file
const content = fs.readFileSync(filePath, 'utf8');
// Split the content based on '&'
const separatedContent = content.split('&');
// Join the separated content with new lines
const newContent = separatedContent.join('\n');
// Write the modified content back to the file
fs.writeFileSync(filePath, newContent);

View File

@@ -0,0 +1,106 @@
/**
* This file contains a script that fetches data from an API and writes it to a file.
* The script makes multiple API calls at regular intervals for a specified duration.
* The fetched data is appended to separate files based on the data center, user tier, and security symbol.
* The script uses Axios for making HTTP requests and the fs module for file operations.
*
* The script exports a function fetchAndWriteApiData that takes an object with the following properties:
* - url: The URL of the API endpoint to fetch data from.
* - headers: An object containing the headers to be sent with the request.
* - dataCenter: The data center to which the API request should be made.
* - userTier: The user tier for which the API request should be made.
* - xid: The xid of the security for which the API request should be made.
* - symbol: The symbol of the security for which the API request should be made.
*
* The script also schedules the API calls to be made every 2 minutes for a duration of 4 hours.
* The start time and stop time are logged to the console.
*/
import axios from 'axios';
import { promises as fs } from 'fs';
import dotenv from 'dotenv';
dotenv.config();
const bearerToken = process.env.BEARER_TOKEN;
const securities = [
{
symbol: 'HOU',
xid: '10020415'
},
{
symbol: 'HZU',
xid: '19728747'
}
];
const dataCenters = ['ptc', 'ctc'];
const users = [
{
userTier: 'QT1a',
modAccessToken: '{"multex":"Y","active":true,"externalId":"testuser","customerTier":5824,"language":"Y","user_tier":"QT1a","token_type":"Bearer","pro":"Y","client_id":"szbv6INGApq0e1Ognvsmzmpq8dGTURTr","realTime":"Y","internalId":"TESTUSER","marketer":"RC","customerType":3870,"levelTwo":"Y","siteId":1614,"exchangeAgreements":"testExchangeAgreements","exp":1689789174}'
},
{
userTier: 'GT2',
modAccessToken: '{"multex":"Y","active":true,"externalId":"testuser","customerTier":5999,"language":"Y","user_tier":"GT2","token_type":"Bearer","pro":"Y","client_id":"szbv6INGApq0e1Ognvsmzmpq8dGTURTr","realTime":"Y","internalId":"TESTUSER","marketer":"RC","customerType":3879,"levelTwo":"Y","siteId":1614,"exchangeAgreements":"testExchangeAgreements","exp":1689789174}'
}
];
async function fetchAndWriteApiData({url, headers, dataCenter, userTier, xid, symbol}) {
try {
await axios.get(url, {}, { headers: { ...headers, Authorization: bearerToken } })
.then(response => {
const datetime = new Date().toISOString();
const responseData = response.data.replace(/<!doctype html><html><body><pre>/, '').split('</pre></body></html>');
console.error(`${dataCenter} as ${userTier} @ ${datetime} - ${symbol} lastTrade.date:`, JSON.parse(responseData[0])?.data?.lastTrade?.date);
const dataToWrite = `Datetime: ${datetime}\nResponse from ${url}:\n${response.data}\n`;
return fs.appendFile(`./output/apiResponses/rbc-quote/${dataCenter}_${userTier}_${xid}.txt`, dataToWrite);
})
.then(() => {
// console.log(`Appended response from ${url} to ${dataCenter}_${userTier}.txt`);
})
.catch(error => {
console.error(`Failed to fetch from ${url} or write to ${dataCenter}_${userTier}_${xid}.txt:`, error);
});
} catch (error) {
console.error('Error:', error);
}
}
// Schedule the calls every 2 minutes for 4 hours
const startTime = new Date().toISOString();
const stopTime = new Date(Date.now() + 4 * 60 * 60 * 1000).toISOString();
const intervalId = setInterval(async () => {
try {
// Create an array of promises based on securities array for the each data senter and the users
const promises = securities.flatMap(security => {
return dataCenters.flatMap(dataCenter => {
return users.map(user => {
return fetchAndWriteApiData({
userTier: user.userTier,
dataCenter: dataCenter,
xid: security.xid,
symbol: security.symbol,
url: `https://api.${dataCenter}.services.mdgapp.net/rbc-quote/v1/${security.xid}?realTime=0&..showdebugdata..=on`, // showdebuginfo was window based we should use showdebugdata
headers: {
'x-mod-access-token': user.modAccessToken
}
});
});
});
});
// Wait for all promises to resolve
await Promise.all(promises);
console.log(`All calls completed successfully at ${new Date().toISOString()}`);
const currentTime = new Date().toISOString();
if (currentTime >= stopTime) {
clearInterval(intervalId);
console.log('Interval stopped after 4 hours');
}
} catch (error) {
console.error('Error:', error);
}
}, 2 * 60 * 1000); // 2 minutes in milliseconds
console.log('Interval started at:', startTime);

View File

@@ -0,0 +1,28 @@
/**
* This script generates a bookmarklet from a JavaScript file.
* It reads the JavaScript file, removes any multiline comments, and creates a bookmarklet string.
* The bookmarklet can then be used to execute the JavaScript code in a browser.
*
* Use this to generate a bookmarklet from a JavaScript file in the utils/bookmarklets directory.
*
* @param {string} filePath - The path to the JavaScript file.
* @returns {string} The generated bookmarklet.
*/
const fs = require('fs');
const path = require('path');
// Get the file path from command line arguments
const filePath = process.argv[2];
// Read the JavaScript file
const jsCode = fs.readFileSync(filePath, 'utf8');
const cleanedCode = jsCode.replace(/\/\*[\s\S]*?\*\//, '');
// Create the bookmarklet
const bookmarklet = `javascript:(function() {
${cleanedCode}
})();`;
console.log(bookmarklet);

View File

@@ -0,0 +1,12 @@
/**
* Opens the API documentation for a given project API.
*
* Requires the use of utils/bookmarkletMaker.js to generate the bookmarklet.
*
* @param {string} projectAPI - The project API to open the documentation for.
*/
const projectAPI = prompt("Please enter the project API:");
if (projectAPI) {
window.open(`https://api.qa.services.mdgapp.net/${projectAPI}/v1/docs`, "_blank").focus();
}

View File

@@ -2,17 +2,17 @@
* Opens the DAG Task details page(s) based on user input.
* If user provides a comma-separated list of DAG Task numbers, it opens each task's details page in a new tab.
* If user does not provide any input, it opens the default DAG Tasks page in a new tab.
*
* Requires the use of utils/bookmarkletMaker.js to generate the bookmarklet.
*/
javascript:(function() {
let answers = prompt("Enter the DAG Task #s, separated by commas");
const splitAnswers = answers ? answers.split(",") : false;
let url = "https://dag.tools.mdgapp.net/Tasks/Tasks.asp";
if (splitAnswers) {
let answers = prompt("Enter the DAG Task #s, separated by commas");
const splitAnswers = answers ? answers.split(",") : false;
let url = "https://dag.tools.mdgapp.net/Tasks/Tasks.asp";
if (splitAnswers) {
splitAnswers.forEach(answer => {
let moidUrl = "https://dag.tools.mdgapp.net/Tasks/TaskDetail.asp?Cmd=Details&TaskID=" + answer.trim();
window.open(moidUrl, '_blank');
});
} else {
} else {
window.open(url, '_blank').focus();
}
})();
}

View File

@@ -9,13 +9,13 @@
* 4. Copies the decoded string to the clipboard.
*
* Note: This function uses the Clipboard API which might not be fully supported in all browsers.
*
* Requires the use of utils/bookmarkletMaker.js to generate the bookmarklet.
*/
javascript:(function() {
let answer = prompt("Enter the HashID");
let decodedStr = decodeURIComponent(answer);
alert(decodedStr);
let answer = prompt("Enter the HashID");
let decodedStr = decodeURIComponent(answer);
alert(decodedStr);
navigator.clipboard.writeText(decodedStr)
navigator.clipboard.writeText(decodedStr)
.then(() => console.log('Decoded string copied to clipboard'))
.catch(err => console.error('Error in copying decoded string to clipboard: ', err));
})();

View File

@@ -10,17 +10,16 @@
* 5. Opens the URL in a new browser tab and brings focus to it.
*
* Note: This function is wrapped in a self-invoking function `(function() {...})();` which means it will automatically execute as soon as it is defined.
* Requires the use of utils/bookmarkletMaker.js to generate the bookmarklet.
*/
javascript:(function() {
let answers = prompt("Enter the JIRA Tickets, separated by commas");
const splitAnswers = answers ? answers.split(",") : false;
let url = "https://fincentric.atlassian.net/jira/software/c/projects/DIP/boards/513";
if (splitAnswers) {
let answers = prompt("Enter the JIRA Tickets, separated by commas");
const splitAnswers = answers ? answers.split(",") : false;
let url = "https://fincentric.atlassian.net/jira/software/c/projects/DIP/boards/513";
if (splitAnswers) {
splitAnswers.forEach(answer => {
let moidUrl = "https://fincentric.atlassian.net/browse/" + answer.trim();
window.open(moidUrl, '_blank');
});
} else {
} else {
window.open(url, '_blank').focus();
}
})();
}

View File

@@ -10,17 +10,16 @@
* 5. Opens each URL in a new browser tab and brings focus to the last opened tab.
*
* Note: This function is wrapped in a self-invoking function `(function() {...})();` which means it will automatically execute as soon as it is defined.
* Requires the use of utils/bookmarkletMaker.js to generate the bookmarklet.
*/
javascript:(function() {
let answers = prompt("Enter the MOID #s, separated by commas");
const splitAnswers = answers ? answers.split(",") : false;
let url = "https://jira.ihsmarkit.com/secure/Dashboard.jspa?selectPageId=63222";
if (splitAnswers) {
let answers = prompt("Enter the MOID #s, separated by commas");
const splitAnswers = answers ? answers.split(",") : false;
let url = "https://jira.ihsmarkit.com/secure/Dashboard.jspa?selectPageId=63222";
if (splitAnswers) {
splitAnswers.forEach(answer => {
let moidUrl = "https://jira.ihsmarkit.com/browse/MOID-" + answer.trim();
window.open(moidUrl, '_blank');
});
} else {
} else {
window.open(url, '_blank').focus();
}
})();
}

View File

@@ -0,0 +1,19 @@
function jsToMsDate(jsdate) {
const ms = Date.UTC(
jsdate.getFullYear(),
jsdate.getMonth(),
jsdate.getDate(),
jsdate.getHours(),
jsdate.getMinutes(),
jsdate.getSeconds(),
jsdate.getMilliseconds()
);
const off = jsdate.getTimezoneOffset();
return (ms - off * 60 * 1000) / 86400000 + 25569;
}
const date = prompt("Enter date");
if (date) {
const parsedDate = new Date(date);
alert(jsToMsDate(parsedDate));
}

View File

@@ -0,0 +1,11 @@
function msToJsDate(msdate) {
const jscriptDateObj = new Date((msdate - 25569) * 86400000);
const timezoneOffset = jscriptDateObj.getTimezoneOffset();
jscriptDateObj.setTime((msdate - 25569 + timezoneOffset / (60 * 24)) * 86400000);
return jscriptDateObj;
}
const date = prompt("Enter MSDate");
if (date) {
alert(msToJsDate(date));
}

View File

@@ -0,0 +1,40 @@
function setFlag(flag, state) {
function setFlagSub(url, flag, state) {
if (!url.includes(flag)) {
url += (url.includes('?') ? '&' : '?');
url += `..${flag}..=${state}`;
} else {
const re = new RegExp(`\\.\\.${flag}\\.\\.=[^&]*`);
url = url.replace(re, `..${flag}..=${state}`);
}
return url;
}
function toggleParameter(ad, type, val) {
type = `..${type}..`;
const regex = new RegExp(`[?|&]${type}=(on|off)&?`);
const match = ad.match(regex);
if (match) {
ad = ad.replace(`${type}=${match[1]}`, `${type}=${val || (match[1] === 'on' ? 'off' : 'on')}`);
} else {
ad += (ad.includes('?') ? '&' : '?') + `${type}=${val || 'on'}`;
}
return ad;
}
const dependencies = {
debugchartsrv: ['showdebuginfo'],
scriptscachedebug: ['scriptscache']
};
let url = window.location.href.replace(/#.*/, '');
if (dependencies[flag] && state !== 'off') {
for (const dependency of dependencies[flag]) {
url = toggleParameter(url, dependency, 'on');
}
}
url = toggleParameter(url, flag, state || null);
window.location.href = url;
}
setFlag('showdebuginfo');

View File

@@ -3,25 +3,26 @@
* It retrieves the feature flags from the session storage, creates checkboxes for each flag,
* and saves the updated flags back to the session storage when the user clicks the save button.
* The modal dialog is appended to the document body and can be closed by clicking the save button.
*
* Requires the use of utils/bookmarkletMaker.js to generate the bookmarklet.
*/
javascript:(function() {
let data = sessionStorage.getItem('rbc_di_session');
let parsedData = JSON.parse(data);
let features = parsedData.features || {};
let data = sessionStorage.getItem('rbc_di_session');
let parsedData = JSON.parse(data);
let features = parsedData.features || {};
let modal = document.createElement('div');
modal.style.position = 'fixed';
modal.style.top = '50%';
modal.style.left = '50%';
modal.style.transform = 'translate(-50%, -50%)';
modal.style.backgroundColor = 'white';
modal.style.padding = '20px';
modal.style.border = '1px solid black';
modal.style.zIndex = '999';
modal.style.display = 'flex';
modal.style.flexWrap = 'wrap';
let modal = document.createElement('div');
modal.style.position = 'fixed';
modal.style.top = '50%';
modal.style.left = '50%';
modal.style.transform = 'translate(-50%, -50%)';
modal.style.backgroundColor = 'white';
modal.style.padding = '20px';
modal.style.border = '1px solid black';
modal.style.zIndex = '999';
modal.style.display = 'flex';
modal.style.flexWrap = 'wrap';
for (let key in features) {
for (let key in features) {
if (features.hasOwnProperty(key) && typeof features[key] === 'boolean') {
let checkboxContainer = document.createElement('div');
checkboxContainer.style.width = '50%';
@@ -39,11 +40,11 @@ javascript:(function() {
checkboxContainer.appendChild(label);
modal.appendChild(checkboxContainer);
}
}
}
let saveButton = document.createElement('button');
saveButton.innerText = 'Save';
saveButton.addEventListener('click', function() {
let saveButton = document.createElement('button');
saveButton.innerText = 'Save';
saveButton.addEventListener('click', function() {
const checkboxes = modal.querySelectorAll('input[type="checkbox"]');
checkboxes.forEach(function(checkbox) {
features[checkbox.id] = checkbox.checked;
@@ -51,46 +52,45 @@ javascript:(function() {
parsedData.features = features;
sessionStorage.setItem('rbc_di_session', JSON.stringify(parsedData));
location.reload();
});
});
let closeButton = document.createElement('button');
closeButton.innerText = 'X';
closeButton.style.position = 'absolute';
closeButton.style.right = '10px';
closeButton.style.top = '10px';
closeButton.addEventListener('click', function() {
let closeButton = document.createElement('button');
closeButton.innerText = 'X';
closeButton.style.position = 'absolute';
closeButton.style.right = '10px';
closeButton.style.top = '10px';
closeButton.addEventListener('click', function() {
document.body.removeChild(modal);
document.body.removeChild(overlay);
});
});
let cancelButton = document.createElement('button');
cancelButton.innerText = 'Cancel';
cancelButton.addEventListener('click', function() {
let cancelButton = document.createElement('button');
cancelButton.innerText = 'Cancel';
cancelButton.addEventListener('click', function() {
document.body.removeChild(modal);
document.body.removeChild(overlay);
});
});
let buttonContainer = document.createElement('div');
buttonContainer.style.width = '100%';
buttonContainer.style.display = 'flex';
buttonContainer.style.justifyContent = 'center';
buttonContainer.style.marginTop = '20px';
let buttonContainer = document.createElement('div');
buttonContainer.style.width = '100%';
buttonContainer.style.display = 'flex';
buttonContainer.style.justifyContent = 'center';
buttonContainer.style.marginTop = '20px';
buttonContainer.appendChild(saveButton);
buttonContainer.appendChild(cancelButton);
buttonContainer.appendChild(saveButton);
buttonContainer.appendChild(cancelButton);
modal.appendChild(closeButton);
modal.appendChild(buttonContainer);
modal.appendChild(closeButton);
modal.appendChild(buttonContainer);
let overlay = document.createElement('div');
overlay.style.position = 'fixed';
overlay.style.top = '0';
overlay.style.left = '0';
overlay.style.width = '100%';
overlay.style.height = '100%';
overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
overlay.style.zIndex = '998';
let overlay = document.createElement('div');
overlay.style.position = 'fixed';
overlay.style.top = '0';
overlay.style.left = '0';
overlay.style.width = '100%';
overlay.style.height = '100%';
overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
overlay.style.zIndex = '998';
document.body.appendChild(overlay);
document.body.appendChild(modal);
})();
document.body.appendChild(overlay);
document.body.appendChild(modal);

View File

@@ -3,10 +3,11 @@
* Deletes the 'fnc-rbc-session' property from the session storage if it exists.
* If the property exists, it prompts the user for confirmation before deleting.
* If the property does not exist, it displays an alert message.
*
* Requires the use of utils/bookmarkletMaker.js to generate the bookmarklet.
*/
javascript: (function () {
const rbcSession = sessionStorage.getItem('fnc-rbc-session');
if (rbcSession) {
const rbcSession = sessionStorage.getItem('fnc-rbc-session');
if (rbcSession) {
const sessionValue = JSON.parse(rbcSession);
let properties = '';
for (const key in sessionValue) {
@@ -17,7 +18,6 @@ javascript: (function () {
sessionStorage.removeItem('fnc-rbc-session');
location.reload();
}
} else {
} else {
alert("'fnc-rbc-session' does not exist in session storage.");
}
})();
}

View File

@@ -4,11 +4,12 @@
* Prompts the user to enter the environment and language in the format 'prod|ste,en|fr'.
* If the input is valid, it opens the corresponding URL in a new tab.
* If the input is invalid, it logs an error message to the console.
*
* Requires the use of utils/bookmarkletMaker.js to generate the bookmarklet.
*/
javascript: (function () {
const answer = prompt("Please enter the env and language in the format 'prod|ste,en|fr':");
const [env, language] = answer.split(",");
switch (env) {
const answer = prompt("Please enter the env and language in the format 'prod|ste,en|fr':");
const [env, language] = answer.split(/,|\s/);
switch (env) {
case "prod":
if (language === "fr") {
window.open("https://www1.royalbank.com/french/netaction/sgnf.html", "_blank").focus();
@@ -25,5 +26,4 @@ javascript: (function () {
break;
default:
console.log("Invalid input");
}
})();
}

View File

@@ -6,9 +6,10 @@ and sets the value of the input field to each security in the array.
It then triggers events to simulate user input and key presses to add the security to the watchlist.
The process repeats for each security in the array with a delay of 2.5 seconds between each iteration.
The code is executed when the bookmarklet is clicked on the web page.
Requires the use of utils/bookmarkletMaker.js to generate the bookmarklet.
*/
javascript: (function () {
const newSecurities = [
const newSecurities = [
'AMX',
'VNORP',
'AMBKP',
@@ -23,8 +24,8 @@ javascript: (function () {
'URW',
'AP.UN',
'PVF.WT'
];
function populateWatchlist() {
];
function populateWatchlist() {
const foundInputs = document.querySelectorAll('.rbc-typeahead-search-input');
const input = foundInputs && foundInputs.length > 1 ? foundInputs[1] : null;
if (input) {
@@ -43,6 +44,5 @@ javascript: (function () {
index++;
}, 2500);
}
}
populateWatchlist();
})();
}
populateWatchlist();

View File

@@ -1,25 +1,24 @@
javascript:(function() {
const urls = {
const urls = {
JIRAMetricsDashboard: "https://fincentric.atlassian.net/jira/dashboards/14019/",
JIRABoard: "https://fincentric.atlassian.net/jira/software/c/projects/DIP/boards/513",
MOIDDashboard: "https://jira.ihsmarkit.com/secure/Dashboard.jspa?selectPageId=63222",
DIUserLoginsConfluencePage: "https://confluence.ihsmarkit.com/pages/viewpage.action?spaceKey=MOD&title=DI+User+Logins#direct-investing--686175318",
WEUserAdmin: "https://intranet.tools.mdgapp.net/P/PTC1/UserAdmin"
};
};
let modal = document.createElement('div');
modal.style.position = 'fixed';
modal.style.top = '50%';
modal.style.left = '50%';
modal.style.transform = 'translate(-50%, -50%)';
modal.style.backgroundColor = 'white';
modal.style.padding = '20px';
modal.style.border = '1px solid black';
modal.style.zIndex = '999';
modal.style.display = 'flex';
modal.style.flexWrap = 'wrap';
let modal = document.createElement('div');
modal.style.position = 'fixed';
modal.style.top = '50%';
modal.style.left = '50%';
modal.style.transform = 'translate(-50%, -50%)';
modal.style.backgroundColor = 'white';
modal.style.padding = '20px';
modal.style.border = '1px solid black';
modal.style.zIndex = '999';
modal.style.display = 'flex';
modal.style.flexWrap = 'wrap';
Object.keys(urls).forEach(key => {
Object.keys(urls).forEach(key => {
let checkboxContainer = document.createElement('div');
checkboxContainer.style.width = '50%';
@@ -36,56 +35,55 @@ javascript:(function() {
checkboxContainer.appendChild(checkbox);
checkboxContainer.appendChild(label);
modal.appendChild(checkboxContainer);
});
});
const startButton = document.createElement('button');
startButton.innerText = 'Start';
startButton.addEventListener('click', () => {
const startButton = document.createElement('button');
startButton.innerText = 'Start';
startButton.addEventListener('click', () => {
const selectedUrls = Array.from(modal.querySelectorAll('input[type="checkbox"]:checked')).map(checkbox => checkbox.value);
selectedUrls.forEach(url => window.open(url, '_blank'));
document.body.removeChild(modal);
document.body.removeChild(overlay);
});
});
let closeButton = document.createElement('button');
closeButton.innerText = 'X';
closeButton.style.position = 'absolute';
closeButton.style.right = '10px';
closeButton.style.top = '10px';
closeButton.addEventListener('click', function() {
let closeButton = document.createElement('button');
closeButton.innerText = 'X';
closeButton.style.position = 'absolute';
closeButton.style.right = '10px';
closeButton.style.top = '10px';
closeButton.addEventListener('click', function() {
document.body.removeChild(modal);
document.body.removeChild(overlay);
});
});
let cancelButton = document.createElement('button');
cancelButton.innerText = 'Cancel';
cancelButton.addEventListener('click', function() {
let cancelButton = document.createElement('button');
cancelButton.innerText = 'Cancel';
cancelButton.addEventListener('click', function() {
document.body.removeChild(modal);
document.body.removeChild(overlay);
});
});
let buttonContainer = document.createElement('div');
buttonContainer.style.width = '100%';
buttonContainer.style.display = 'flex';
buttonContainer.style.justifyContent = 'center';
buttonContainer.style.marginTop = '20px';
let buttonContainer = document.createElement('div');
buttonContainer.style.width = '100%';
buttonContainer.style.display = 'flex';
buttonContainer.style.justifyContent = 'center';
buttonContainer.style.marginTop = '20px';
buttonContainer.appendChild(startButton);
buttonContainer.appendChild(cancelButton);
buttonContainer.appendChild(startButton);
buttonContainer.appendChild(cancelButton);
modal.appendChild(closeButton);
modal.appendChild(buttonContainer);
modal.appendChild(closeButton);
modal.appendChild(buttonContainer);
let overlay = document.createElement('div');
overlay.style.position = 'fixed';
overlay.style.top = '0';
overlay.style.left = '0';
overlay.style.width = '100%';
overlay.style.height = '100%';
overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
overlay.style.zIndex = '998';
let overlay = document.createElement('div');
overlay.style.position = 'fixed';
overlay.style.top = '0';
overlay.style.left = '0';
overlay.style.width = '100%';
overlay.style.height = '100%';
overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
overlay.style.zIndex = '998';
document.body.appendChild(overlay);
document.body.appendChild(modal);
})();
document.body.appendChild(overlay);
document.body.appendChild(modal);

View File

@@ -5,8 +5,8 @@
* markdown links for each file. Then, it updates the README file with the generated links
* and descriptions.
*/
const fs = require('fs');
const path = require('path');
import fs from 'fs';
import path from 'path';
const resolvedPath = path.resolve();
console.log(resolvedPath);

View File

@@ -1,21 +0,0 @@
javascript:(function() {
function jsToMsDate(jsdate) {
var ms = Date.UTC(
jsdate.getUTCFullYear(),
jsdate.getUTCMonth(),
jsdate.getUTCDate(),
jsdate.getUTCHours(),
jsdate.getUTCMinutes(),
jsdate.getUTCSeconds(),
jsdate.getUTCMilliseconds()
);
var off = jsdate.getTimezoneOffset();
return (ms - off * 60 * 1000) / 86400000 + 25569;
}
var date = prompt("Enter date");
if (date) {
date = new Date(date);
alert(jsToMsDate(date)); }
})();

View File

@@ -1,13 +0,0 @@
javascript:(function() {
function msToJsDate(msdate) {
var jscriptDateObj = new Date(((msdate - 25569) * 86400000));
var timezoneOffset = jscriptDateObj.getTimezoneOffset();
jscriptDateObj = new Date(((msdate - 25569 + (timezoneOffset / (60 * 24))) * 86400000));
return jscriptDateObj;
}
var date = prompt("Enter MSDate");
if (date) {
alert(msToJsDate(date));
}
})();

View File

@@ -1,40 +0,0 @@
// eslint-disable-next-line no-use-before-define
javascript: (function () {
function setFlag(_flag, _state) {
function setFlagSub(_url, _flag, _state) {
if (_url.indexOf(_flag) == -1) {
_url += (/\?/.test(_url)) ? '&' : '?';
_url += '..' + _flag + '..=' + _state;
} else {
var re = new RegExp('\\.\\.' + _flag + '\\.\\.=[^&]*');
_url = _url.replace(re, '..' + _flag + '..=' + _state);
}
return _url;
};
function toggleParameter(ad, type, val) {
type = '..' + type + '..';
if (m = ad.match(new RegExp('[?|&]' + type + '=(on|off)&?'))) {
ad = ad.replace(type + '=' + m[1], type + '=' + (val || (m[1] == 'on' ? 'off' : 'on')));
} else {
ad += (/\?/.test(ad) ? '&' : '?') + type + '=' + (val || 'on');
}
return ad;
};
var dependencies = {
'debugchartsrv': ['showdebuginfo'],
'scriptscachedebug': ['scriptscache']
};
var url = new String(window.location.href).replace(/#.*/,);
if (dependencies[_flag] && _state != 'off') {
for (var i = 0; i < dependencies[_flag].length; i++) {
url = toggleParameter(url, dependencies[_flag][i], 'on');
}
}
url = toggleParameter(url, _flag, _state || null);
window.location.href = url;
};
setFlag('showdebuginfo');
})();