From e2c5035011a40bc817e6dfe16980f6b50e1b73f9 Mon Sep 17 00:00:00 2001 From: Greg Jacobs Date: Wed, 12 Jun 2024 13:04:47 -0400 Subject: [PATCH] Updated all bookmarklets to just be functions and we can use utils/bookmarkletMaker.js to generate the bookmarklets in the console for now. --- .gitignore | 11 +- README.MD | 52 +++--- package.json | 11 +- src/ideas/RBCDict.txt | 24 +++ src/ideas/newideashere.txt | 6 + src/ideas/split.js | 15 ++ src/utils/apiResponseChecker.js | 106 ++++++++++++ src/utils/bookmarkletMaker.js | 28 ++++ src/utils/bookmarklets/apiDocs.js | 12 ++ src/utils/bookmarklets/dag.js | 26 +-- src/utils/bookmarklets/hashid.js | 16 +- src/utils/bookmarklets/jira.js | 25 ++- src/utils/bookmarklets/moids.js | 25 ++- src/utils/bookmarklets/notMine/jsToMsDate.js | 19 +++ src/utils/bookmarklets/notMine/msToJsDate.js | 11 ++ .../bookmarklets/notMine/showDebugInfo.js | 40 +++++ src/utils/bookmarklets/rbc-di-featureflags.js | 154 ++++++++--------- src/utils/bookmarklets/rbcSessionStorage.js | 32 ++-- src/utils/bookmarklets/rbcSiteNavigator.js | 44 ++--- .../bookmarklets/rbcWatchlistPopulator.js | 76 ++++----- src/utils/bookmarklets/workspace.js | 156 +++++++++--------- src/utils/git/updateReadme.js | 4 +- src/utils/importBookmarkMaker.js | 0 src/utils/others/jsToMsDate.js | 21 --- src/utils/others/msToJsDate.js | 13 -- src/utils/others/showDebugInfo.js | 40 ----- 26 files changed, 587 insertions(+), 380 deletions(-) create mode 100644 src/ideas/RBCDict.txt create mode 100644 src/ideas/split.js create mode 100644 src/utils/apiResponseChecker.js create mode 100644 src/utils/bookmarkletMaker.js create mode 100644 src/utils/bookmarklets/apiDocs.js create mode 100644 src/utils/bookmarklets/notMine/jsToMsDate.js create mode 100644 src/utils/bookmarklets/notMine/msToJsDate.js create mode 100644 src/utils/bookmarklets/notMine/showDebugInfo.js delete mode 100644 src/utils/importBookmarkMaker.js delete mode 100644 src/utils/others/jsToMsDate.js delete mode 100644 src/utils/others/msToJsDate.js delete mode 100644 src/utils/others/showDebugInfo.js diff --git a/.gitignore b/.gitignore index 0f0e1b7..a4be0e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,12 @@ +# The usual suspects in frontend dev package-lock.json node_modules/ -codingstandards.txt \ No newline at end of file + +# References used by copilot +references/ + +#Static files created by apps +output/ + +# Environment variables +.env \ No newline at end of file diff --git a/README.MD b/README.MD index ba16bec..39cd35a 100644 --- a/README.MD +++ b/README.MD @@ -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. - 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) + 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. + ## [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. If user does not provide any input, it opens the default DAG Tasks page in a new tab. + 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. ## [hashid.js](src\utils\bookmarklets\hashid.js) - 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. Note: This function uses the Clipboard API which might not be fully supported in all browsers. + 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. 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. ## [jira.js](src\utils\bookmarklets\jira.js) - This JavaScript function is a bookmarklet that prompts the user for a JIRA ticket number and then opens a new browser tab with the corresponding JIRA page for that ticket. The function works as follows: 1. Prompts the user to enter a JIRA ticket number. The entered value is stored in the `answer` variable. 2. Sets a default URL to the JIRA dashboard. 3. Checks if the user entered a value in the prompt. 4. If the user entered a value, changes the URL to point to the specific JIRA page for the entered ticket number. 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. + This JavaScript function is a bookmarklet that prompts the user for a JIRA ticket number and then opens a new browser tab with the corresponding JIRA page for that ticket. The function works as follows: 1. Prompts the user to enter a JIRA ticket number. The entered value is stored in the `answer` variable. 2. Sets a default URL to the JIRA dashboard. 3. Checks if the user entered a value in the prompt. 4. If the user entered a value, changes the URL to point to the specific JIRA page for the entered ticket number. 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. ## [moids.js](src\utils\bookmarklets\moids.js) - This JavaScript function is a bookmarklet that prompts the user for multiple MOID (Markit On Demand) numbers 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. + This JavaScript function is a bookmarklet that prompts the user for multiple MOID (Markit On Demand) numbers 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. Requires the use of utils/bookmarkletMaker.js to generate the bookmarklet. + +## [jsToMsDate.js](src\utils\bookmarklets\notMine\jsToMsDate.js) +No Description Provided + +## [msToJsDate.js](src\utils\bookmarklets\notMine\msToJsDate.js) +No Description Provided + +## [showDebugInfo.js](src\utils\bookmarklets\notMine\showDebugInfo.js) +No Description Provided ## [rbc-di-featureflags.js](src\utils\bookmarklets\rbc-di-featureflags.js) - This function creates a modal dialog that allows the user to toggle feature flags. 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. + This function creates a modal dialog that allows the user to toggle feature flags. 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. ## [rbcSessionStorage.js](src\utils\bookmarklets\rbcSessionStorage.js) - 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. + 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. ## [rbcSiteNavigator.js](src\utils\bookmarklets\rbcSiteNavigator.js) - Opens a specific URL based on the provided environment and language. 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. + Opens a specific URL based on the provided environment and language. 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. ## [rbcWatchlistPopulator.js](src\utils\bookmarklets\rbcWatchlistPopulator.js) @@ -33,22 +51,12 @@ The function finds the input field on the page, iterates over the new securities 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. +The code is executed when the bookmarklet is clicked on the web page. + +Requires the use of utils/bookmarkletMaker.js to generate the bookmarklet. ## [workspace.js](src\utils\bookmarklets\workspace.js) No Description Provided ## [updateReadme.js](src\utils\git\updateReadme.js) - This file is responsible for updating the README file with file links and descriptions. It reads the files in the specified directory, extracts their descriptions, and generates markdown links for each file. Then, it updates the README file with the generated links and descriptions. - -## [importBookmarkMaker.js](src\utils\importBookmarkMaker.js) -No Description Provided - -## [jsToMsDate.js](src\utils\others\jsToMsDate.js) -No Description Provided - -## [msToJsDate.js](src\utils\others\msToJsDate.js) -No Description Provided - -## [showDebugInfo.js](src\utils\others\showDebugInfo.js) -No Description Provided \ No newline at end of file + This file is responsible for updating the README file with file links and descriptions. It reads the files in the specified directory, extracts their descriptions, and generates markdown links for each file. Then, it updates the README file with the generated links and descriptions. \ No newline at end of file diff --git a/package.json b/package.json index edcfc05..4c96359 100644 --- a/package.json +++ b/package.json @@ -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" + "format": "prettier src --write --ignore-unknown", + "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" } } diff --git a/src/ideas/RBCDict.txt b/src/ideas/RBCDict.txt new file mode 100644 index 0000000..c6d6a37 --- /dev/null +++ b/src/ideas/RBCDict.txt @@ -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 \ No newline at end of file diff --git a/src/ideas/newideashere.txt b/src/ideas/newideashere.txt index 8e51317..fc9a90e 100644 --- a/src/ideas/newideashere.txt +++ b/src/ideas/newideashere.txt @@ -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 + diff --git a/src/ideas/split.js b/src/ideas/split.js new file mode 100644 index 0000000..77a8038 --- /dev/null +++ b/src/ideas/split.js @@ -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); \ No newline at end of file diff --git a/src/utils/apiResponseChecker.js b/src/utils/apiResponseChecker.js new file mode 100644 index 0000000..0df1048 --- /dev/null +++ b/src/utils/apiResponseChecker.js @@ -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(/
/, '').split('
'); + 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); \ No newline at end of file diff --git a/src/utils/bookmarkletMaker.js b/src/utils/bookmarkletMaker.js new file mode 100644 index 0000000..9498640 --- /dev/null +++ b/src/utils/bookmarkletMaker.js @@ -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); \ No newline at end of file diff --git a/src/utils/bookmarklets/apiDocs.js b/src/utils/bookmarklets/apiDocs.js new file mode 100644 index 0000000..aff4b7f --- /dev/null +++ b/src/utils/bookmarklets/apiDocs.js @@ -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(); +} diff --git a/src/utils/bookmarklets/dag.js b/src/utils/bookmarklets/dag.js index f1d83af..ea9bb02 100644 --- a/src/utils/bookmarklets/dag.js +++ b/src/utils/bookmarklets/dag.js @@ -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) { - splitAnswers.forEach(answer => { - let moidUrl = "https://dag.tools.mdgapp.net/Tasks/TaskDetail.asp?Cmd=Details&TaskID=" + answer.trim(); - window.open(moidUrl, '_blank'); - }); - } else { - window.open(url, '_blank').focus(); - } -})(); \ No newline at end of file +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 { + window.open(url, '_blank').focus(); +} \ No newline at end of file diff --git a/src/utils/bookmarklets/hashid.js b/src/utils/bookmarklets/hashid.js index 69383b7..159faee 100644 --- a/src/utils/bookmarklets/hashid.js +++ b/src/utils/bookmarklets/hashid.js @@ -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) - .then(() => console.log('Decoded string copied to clipboard')) - .catch(err => console.error('Error in copying decoded string to clipboard: ', err)); -})(); \ No newline at end of file +navigator.clipboard.writeText(decodedStr) + .then(() => console.log('Decoded string copied to clipboard')) + .catch(err => console.error('Error in copying decoded string to clipboard: ', err)); diff --git a/src/utils/bookmarklets/jira.js b/src/utils/bookmarklets/jira.js index b698361..7ac8074 100644 --- a/src/utils/bookmarklets/jira.js +++ b/src/utils/bookmarklets/jira.js @@ -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) { - splitAnswers.forEach(answer => { - let moidUrl = "https://fincentric.atlassian.net/browse/" + answer.trim(); - window.open(moidUrl, '_blank'); - }); - } else { - window.open(url, '_blank').focus(); - } -})(); \ No newline at end of file +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 { + window.open(url, '_blank').focus(); +} diff --git a/src/utils/bookmarklets/moids.js b/src/utils/bookmarklets/moids.js index 20d8a6d..1038584 100644 --- a/src/utils/bookmarklets/moids.js +++ b/src/utils/bookmarklets/moids.js @@ -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) { - splitAnswers.forEach(answer => { - let moidUrl = "https://jira.ihsmarkit.com/browse/MOID-" + answer.trim(); - window.open(moidUrl, '_blank'); - }); - } else { - window.open(url, '_blank').focus(); - } -})(); \ No newline at end of file +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 { + window.open(url, '_blank').focus(); +} \ No newline at end of file diff --git a/src/utils/bookmarklets/notMine/jsToMsDate.js b/src/utils/bookmarklets/notMine/jsToMsDate.js new file mode 100644 index 0000000..8586c8a --- /dev/null +++ b/src/utils/bookmarklets/notMine/jsToMsDate.js @@ -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)); +} \ No newline at end of file diff --git a/src/utils/bookmarklets/notMine/msToJsDate.js b/src/utils/bookmarklets/notMine/msToJsDate.js new file mode 100644 index 0000000..7692306 --- /dev/null +++ b/src/utils/bookmarklets/notMine/msToJsDate.js @@ -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)); +} diff --git a/src/utils/bookmarklets/notMine/showDebugInfo.js b/src/utils/bookmarklets/notMine/showDebugInfo.js new file mode 100644 index 0000000..c840d60 --- /dev/null +++ b/src/utils/bookmarklets/notMine/showDebugInfo.js @@ -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'); diff --git a/src/utils/bookmarklets/rbc-di-featureflags.js b/src/utils/bookmarklets/rbc-di-featureflags.js index 7f2b9d3..cd4cd9b 100644 --- a/src/utils/bookmarklets/rbc-di-featureflags.js +++ b/src/utils/bookmarklets/rbc-di-featureflags.js @@ -3,94 +3,94 @@ * 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) { - if (features.hasOwnProperty(key) && typeof features[key] === 'boolean') { - let checkboxContainer = document.createElement('div'); - checkboxContainer.style.width = '50%'; +for (let key in features) { + if (features.hasOwnProperty(key) && typeof features[key] === 'boolean') { + let checkboxContainer = document.createElement('div'); + checkboxContainer.style.width = '50%'; - let checkbox = document.createElement('input'); - checkbox.type = 'checkbox'; - checkbox.id = key; - checkbox.checked = features[key]; + let checkbox = document.createElement('input'); + checkbox.type = 'checkbox'; + checkbox.id = key; + checkbox.checked = features[key]; - let label = document.createElement('label'); - label.htmlFor = key; - label.innerText = key; + let label = document.createElement('label'); + label.htmlFor = key; + label.innerText = key; - checkboxContainer.appendChild(checkbox); - checkboxContainer.appendChild(label); - modal.appendChild(checkboxContainer); - } - } + checkboxContainer.appendChild(checkbox); + checkboxContainer.appendChild(label); + modal.appendChild(checkboxContainer); + } +} - 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; - }); - parsedData.features = features; - sessionStorage.setItem('rbc_di_session', JSON.stringify(parsedData)); - location.reload(); - }); +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; + }); + 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() { - 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() { + document.body.removeChild(modal); + document.body.removeChild(overlay); +}); - let cancelButton = document.createElement('button'); - cancelButton.innerText = 'Cancel'; - cancelButton.addEventListener('click', function() { - document.body.removeChild(modal); - document.body.removeChild(overlay); - }); +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); -})(); \ No newline at end of file +document.body.appendChild(overlay); +document.body.appendChild(modal); diff --git a/src/utils/bookmarklets/rbcSessionStorage.js b/src/utils/bookmarklets/rbcSessionStorage.js index fe004b8..236cf9f 100644 --- a/src/utils/bookmarklets/rbcSessionStorage.js +++ b/src/utils/bookmarklets/rbcSessionStorage.js @@ -3,21 +3,21 @@ * 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 sessionValue = JSON.parse(rbcSession); - let properties = ''; - for (const key in sessionValue) { - properties += `${key}: ${sessionValue[key]}\n`; - } - const confirmDelete = confirm(`The properties in 'fnc-rbc-session' are:\n\n${properties}\nDo you want to delete 'fnc-rbc-session'?`); - if (confirmDelete) { - sessionStorage.removeItem('fnc-rbc-session'); - location.reload(); - } - } else { - alert("'fnc-rbc-session' does not exist in session storage."); +const rbcSession = sessionStorage.getItem('fnc-rbc-session'); +if (rbcSession) { + const sessionValue = JSON.parse(rbcSession); + let properties = ''; + for (const key in sessionValue) { + properties += `${key}: ${sessionValue[key]}\n`; } -})(); + const confirmDelete = confirm(`The properties in 'fnc-rbc-session' are:\n\n${properties}\nDo you want to delete 'fnc-rbc-session'?`); + if (confirmDelete) { + sessionStorage.removeItem('fnc-rbc-session'); + location.reload(); + } +} else { + alert("'fnc-rbc-session' does not exist in session storage."); +} \ No newline at end of file diff --git a/src/utils/bookmarklets/rbcSiteNavigator.js b/src/utils/bookmarklets/rbcSiteNavigator.js index 37bda70..8e4adf9 100644 --- a/src/utils/bookmarklets/rbcSiteNavigator.js +++ b/src/utils/bookmarklets/rbcSiteNavigator.js @@ -4,26 +4,26 @@ * 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) { - case "prod": - if (language === "fr") { - window.open("https://www1.royalbank.com/french/netaction/sgnf.html", "_blank").focus(); - } else { - window.open("https://www1.royalbank.com/english/netaction/sgne.html", "_blank").focus(); - } - break; - case "ste": - if (language === "fr") { - window.open("https://www1.steroyalbank.com/french/netaction/sgnf.html", "_blank").focus(); - } else { - window.open("https://www1.steroyalbank.com/english/netaction/sgne.html", "_blank").focus(); - } - break; - default: - console.log("Invalid input"); - } -})(); \ No newline at end of file +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(); + } else { + window.open("https://www1.royalbank.com/english/netaction/sgne.html", "_blank").focus(); + } + break; + case "ste": + if (language === "fr") { + window.open("https://www1.steroyalbank.com/french/netaction/sgnf.html", "_blank").focus(); + } else { + window.open("https://www1.steroyalbank.com/english/netaction/sgne.html", "_blank").focus(); + } + break; + default: + console.log("Invalid input"); +} \ No newline at end of file diff --git a/src/utils/bookmarklets/rbcWatchlistPopulator.js b/src/utils/bookmarklets/rbcWatchlistPopulator.js index bcee6a8..c31f18f 100644 --- a/src/utils/bookmarklets/rbcWatchlistPopulator.js +++ b/src/utils/bookmarklets/rbcWatchlistPopulator.js @@ -6,43 +6,43 @@ 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 = [ - 'AMX', - 'VNORP', - 'AMBKP', - 'CSU.DB', - 'NFLX', - 'ICFSSUSN', - 'ICRP', - 'LDSVF', - 'AMTPQ', - 'DSHKP', - 'AITRR', - 'URW', - 'AP.UN', - 'PVF.WT' - ]; - function populateWatchlist() { - const foundInputs = document.querySelectorAll('.rbc-typeahead-search-input'); - const input = foundInputs && foundInputs.length > 1 ? foundInputs[1] : null; - if (input) { - let index = 0; - const interval = setInterval(() => { - if (index >= newSecurities.length) { - clearInterval(interval); - return; - } - input.value = newSecurities[index]; - input.dispatchEvent(new Event('input', { bubbles: true })); - input.dispatchEvent(new Event('change', { bubbles: true })); - setTimeout(() => { - input.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 13 })); - }, 1000); - index++; - }, 2500); - } +const newSecurities = [ + 'AMX', + 'VNORP', + 'AMBKP', + 'CSU.DB', + 'NFLX', + 'ICFSSUSN', + 'ICRP', + 'LDSVF', + 'AMTPQ', + 'DSHKP', + 'AITRR', + 'URW', + 'AP.UN', + 'PVF.WT' +]; +function populateWatchlist() { + const foundInputs = document.querySelectorAll('.rbc-typeahead-search-input'); + const input = foundInputs && foundInputs.length > 1 ? foundInputs[1] : null; + if (input) { + let index = 0; + const interval = setInterval(() => { + if (index >= newSecurities.length) { + clearInterval(interval); + return; + } + input.value = newSecurities[index]; + input.dispatchEvent(new Event('input', { bubbles: true })); + input.dispatchEvent(new Event('change', { bubbles: true })); + setTimeout(() => { + input.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 13 })); + }, 1000); + index++; + }, 2500); } - populateWatchlist(); -})(); +} +populateWatchlist(); diff --git a/src/utils/bookmarklets/workspace.js b/src/utils/bookmarklets/workspace.js index 63e571b..08abb48 100644 --- a/src/utils/bookmarklets/workspace.js +++ b/src/utils/bookmarklets/workspace.js @@ -1,91 +1,89 @@ -javascript:(function() { - 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" - }; +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'; + +Object.keys(urls).forEach(key => { + let checkboxContainer = document.createElement('div'); + checkboxContainer.style.width = '50%'; + + const checkbox = document.createElement('input'); + checkbox.type = 'checkbox'; + checkbox.id = key; + checkbox.name = key; + checkbox.value = urls[key]; - 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'; + const label = document.createElement('label'); + label.htmlFor = key; + label.innerText = key.split(/(?=[A-Z][a-z])/).join(' '); + + checkboxContainer.appendChild(checkbox); + checkboxContainer.appendChild(label); + modal.appendChild(checkboxContainer); +}); - Object.keys(urls).forEach(key => { - let checkboxContainer = document.createElement('div'); - checkboxContainer.style.width = '50%'; +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); +}); - const checkbox = document.createElement('input'); - checkbox.type = 'checkbox'; - checkbox.id = key; - checkbox.name = key; - checkbox.value = urls[key]; - - const label = document.createElement('label'); - label.htmlFor = key; - label.innerText = key.split(/(?=[A-Z][a-z])/).join(' '); - - checkboxContainer.appendChild(checkbox); - checkboxContainer.appendChild(label); - modal.appendChild(checkboxContainer); - }); - - 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')); +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 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() { + document.body.removeChild(modal); + document.body.removeChild(overlay); +}); - 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); diff --git a/src/utils/git/updateReadme.js b/src/utils/git/updateReadme.js index b2c4b17..1d50f86 100644 --- a/src/utils/git/updateReadme.js +++ b/src/utils/git/updateReadme.js @@ -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); diff --git a/src/utils/importBookmarkMaker.js b/src/utils/importBookmarkMaker.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/utils/others/jsToMsDate.js b/src/utils/others/jsToMsDate.js deleted file mode 100644 index 3109260..0000000 --- a/src/utils/others/jsToMsDate.js +++ /dev/null @@ -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)); } - -})(); \ No newline at end of file diff --git a/src/utils/others/msToJsDate.js b/src/utils/others/msToJsDate.js deleted file mode 100644 index cb8532b..0000000 --- a/src/utils/others/msToJsDate.js +++ /dev/null @@ -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)); - } -})(); \ No newline at end of file diff --git a/src/utils/others/showDebugInfo.js b/src/utils/others/showDebugInfo.js deleted file mode 100644 index a437478..0000000 --- a/src/utils/others/showDebugInfo.js +++ /dev/null @@ -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'); -})(); \ No newline at end of file