Skip to content

Commit 27edb37

Browse files
committed
Renamed rePatterns to regEx
1 parent d6f262f commit 27edb37

File tree

8 files changed

+56
-56
lines changed

8 files changed

+56
-56
lines changed

amazongpt/utils/bump/resources.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
br = '\x1b[1;91m' // bright red
2323

2424
// Init REGEX
25-
const rePatterns = {
25+
const regEx = {
2626
resName: /[^/]+\/(?:css|dist)?\/?[^/]+\.(?:css|js)(?=[?#]|$)/,
2727
jsURL: /^\/\/ @require\s+(https:\/\/cdn\.jsdelivr\.net\/gh\/.+)$/,
2828
commitHash: /(@|\?v=)([^/#]+)/, sriHash: /[^#]+$/
@@ -101,7 +101,7 @@
101101
// Collect resourcs
102102
log.working('\nCollecting resources...\n')
103103
const userJScontent = fs.readFileSync(userJSfilePath, 'utf-8'),
104-
reResURL = new RegExp(rePatterns.jsURL.source, 'gm'),
104+
reResURL = new RegExp(regEx.jsURL.source, 'gm'),
105105
resURLs = [...userJScontent.matchAll(reResURL)].map(match => match[1] || match[2])
106106
log.success(`${resURLs.length} potentially bumpable resource(s) found.`)
107107

@@ -121,27 +121,27 @@
121121
// Process each resource
122122
for (const resURL of resURLs) {
123123
if (!await isValidResource(resURL)) continue // to next resource
124-
const resName = rePatterns.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
124+
const resName = regEx.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
125125

126126
// Compare/update commit hash
127127
let resLatestCommitHash = latestCommitHashes[resURL.includes(repoName) ? 'chromium' : 'aiweb']
128128
if (resLatestCommitHash.startsWith( // compare hashes
129-
rePatterns.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
129+
regEx.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
130130
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
131131
continue // ...so skip resource
132132
}
133133
resLatestCommitHash = resLatestCommitHash.substring(0, 7) // abbr it
134-
let updatedURL = resURL.replace(rePatterns.commitHash, `$1${resLatestCommitHash}`) // update hash
134+
let updatedURL = resURL.replace(regEx.commitHash, `$1${resLatestCommitHash}`) // update hash
135135
if (!await isValidResource(updatedURL)) continue // to next resource
136136

137137
// Generate/compare/update SRI hash
138138
console.log(`${ !log.endedWithLineBreak ? '\n' : '' }Generating SRI (SHA-256) hash for ${resName}...`)
139139
const newSRIhash = await generateSRIhash(updatedURL)
140-
if (rePatterns.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
140+
if (regEx.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
141141
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
142142
continue // ...so skip resource
143143
}
144-
updatedURL = updatedURL.replace(rePatterns.sriHash, newSRIhash) // update hash
144+
updatedURL = updatedURL.replace(regEx.sriHash, newSRIhash) // update hash
145145
if (!await isValidResource(updatedURL)) continue // to next resource
146146

147147
// Write updated URL to userscript

bravegpt/utils/bump/resources.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
br = '\x1b[1;91m' // bright red
2323

2424
// Init REGEX
25-
const rePatterns = {
25+
const regEx = {
2626
resName: /[^/]+\/(?:css|dist)?\/?[^/]+\.(?:css|js)(?=[?#]|$)/,
2727
jsURL: /^\/\/ @require\s+(https:\/\/cdn\.jsdelivr\.net\/gh\/.+)$/,
2828
commitHash: /(@|\?v=)([^/#]+)/, sriHash: /[^#]+$/
@@ -101,7 +101,7 @@
101101
// Collect resourcs
102102
log.working('\nCollecting resources...\n')
103103
const userJScontent = fs.readFileSync(userJSfilePath, 'utf-8'),
104-
reResURL = new RegExp(rePatterns.jsURL.source, 'gm'),
104+
reResURL = new RegExp(regEx.jsURL.source, 'gm'),
105105
resURLs = [...userJScontent.matchAll(reResURL)].map(match => match[1] || match[2])
106106
log.success(`${resURLs.length} potentially bumpable resource(s) found.`)
107107

@@ -121,27 +121,27 @@
121121
// Process each resource
122122
for (const resURL of resURLs) {
123123
if (!await isValidResource(resURL)) continue // to next resource
124-
const resName = rePatterns.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
124+
const resName = regEx.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
125125

126126
// Compare/update commit hash
127127
let resLatestCommitHash = latestCommitHashes[resURL.includes(repoName) ? 'chromium' : 'aiweb']
128128
if (resLatestCommitHash.startsWith( // compare hashes
129-
rePatterns.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
129+
regEx.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
130130
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
131131
continue // ...so skip resource
132132
}
133133
resLatestCommitHash = resLatestCommitHash.substring(0, 7) // abbr it
134-
let updatedURL = resURL.replace(rePatterns.commitHash, `$1${resLatestCommitHash}`) // update hash
134+
let updatedURL = resURL.replace(regEx.commitHash, `$1${resLatestCommitHash}`) // update hash
135135
if (!await isValidResource(updatedURL)) continue // to next resource
136136

137137
// Generate/compare/update SRI hash
138138
console.log(`${ !log.endedWithLineBreak ? '\n' : '' }Generating SRI (SHA-256) hash for ${resName}...`)
139139
const newSRIhash = await generateSRIhash(updatedURL)
140-
if (rePatterns.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
140+
if (regEx.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
141141
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
142142
continue // ...so skip resource
143143
}
144-
updatedURL = updatedURL.replace(rePatterns.sriHash, newSRIhash) // update hash
144+
updatedURL = updatedURL.replace(regEx.sriHash, newSRIhash) // update hash
145145
if (!await isValidResource(updatedURL)) continue // to next resource
146146

147147
// Write updated URL to userscript

chatgpt-auto-continue/utils/bump/resources.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
br = '\x1b[1;91m' // bright red
2727

2828
// Init REGEX
29-
const rePatterns = {
29+
const regEx = {
3030
resName: /[^/]+\/(?:css|dist)?\/?[^/]+\.(?:css|js)(?=[?#]|$)/,
3131
jsURL: /^\/\/ @require\s+(https:\/\/cdn\.jsdelivr\.net\/gh\/.+)$/,
3232
commitHash: /(@|\?v=)([^/#]+)/, sriHash: /[^#]+$/
@@ -105,7 +105,7 @@
105105
// Collect resourcs
106106
log.working('\nCollecting resources...\n')
107107
const userJScontent = fs.readFileSync(userJSfilePath, 'utf-8'),
108-
reResURL = new RegExp(rePatterns.jsURL.source, 'gm'),
108+
reResURL = new RegExp(regEx.jsURL.source, 'gm'),
109109
resURLs = [...userJScontent.matchAll(reResURL)].map(match => match[1] || match[2])
110110
log.success(`${resURLs.length} potentially bumpable resource(s) found.`)
111111

@@ -125,27 +125,27 @@
125125
// Process each resource
126126
for (const resURL of resURLs) {
127127
if (!await isValidResource(resURL)) continue // to next resource
128-
const resName = rePatterns.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
128+
const resName = regEx.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
129129

130130
// Compare/update commit hash
131131
let resLatestCommitHash = latestCommitHashes[resURL.includes(repoName) ? 'chromium' : 'aiweb']
132132
if (resLatestCommitHash.startsWith( // compare hashes
133-
rePatterns.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
133+
regEx.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
134134
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
135135
continue // ...so skip resource
136136
}
137137
resLatestCommitHash = resLatestCommitHash.substring(0, 7) // abbr it
138-
let updatedURL = resURL.replace(rePatterns.commitHash, `$1${resLatestCommitHash}`) // update hash
138+
let updatedURL = resURL.replace(regEx.commitHash, `$1${resLatestCommitHash}`) // update hash
139139
if (!await isValidResource(updatedURL)) continue // to next resource
140140

141141
// Generate/compare/update SRI hash
142142
console.log(`${ !log.endedWithLineBreak ? '\n' : '' }Generating SRI (SHA-256) hash for ${resName}...`)
143143
const newSRIhash = await generateSRIhash(updatedURL)
144-
if (rePatterns.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
144+
if (regEx.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
145145
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
146146
continue // ...so skip resource
147147
}
148-
updatedURL = updatedURL.replace(rePatterns.sriHash, newSRIhash) // update hash
148+
updatedURL = updatedURL.replace(regEx.sriHash, newSRIhash) // update hash
149149
if (!await isValidResource(updatedURL)) continue // to next resource
150150

151151
// Write updated URL to userscript

chatgpt-infinity/utils/bump/resources.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
br = '\x1b[1;91m' // bright red
2727

2828
// Init REGEX
29-
const rePatterns = {
29+
const regEx = {
3030
resName: /[^/]+\/(?:css|dist)?\/?[^/]+\.(?:css|js)(?=[?#]|$)/,
3131
jsURL: /^\/\/ @require\s+(https:\/\/cdn\.jsdelivr\.net\/gh\/.+)$/,
3232
commitHash: /(@|\?v=)([^/#]+)/, sriHash: /[^#]+$/
@@ -105,7 +105,7 @@
105105
// Collect resourcs
106106
log.working('\nCollecting resources...\n')
107107
const userJScontent = fs.readFileSync(userJSfilePath, 'utf-8'),
108-
reResURL = new RegExp(rePatterns.jsURL.source, 'gm'),
108+
reResURL = new RegExp(regEx.jsURL.source, 'gm'),
109109
resURLs = [...userJScontent.matchAll(reResURL)].map(match => match[1] || match[2])
110110
log.success(`${resURLs.length} potentially bumpable resource(s) found.`)
111111

@@ -125,27 +125,27 @@
125125
// Process each resource
126126
for (const resURL of resURLs) {
127127
if (!await isValidResource(resURL)) continue // to next resource
128-
const resName = rePatterns.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
128+
const resName = regEx.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
129129

130130
// Compare/update commit hash
131131
let resLatestCommitHash = latestCommitHashes[resURL.includes(repoName) ? 'chromium' : 'aiweb']
132132
if (resLatestCommitHash.startsWith( // compare hashes
133-
rePatterns.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
133+
regEx.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
134134
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
135135
continue // ...so skip resource
136136
}
137137
resLatestCommitHash = resLatestCommitHash.substring(0, 7) // abbr it
138-
let updatedURL = resURL.replace(rePatterns.commitHash, `$1${resLatestCommitHash}`) // update hash
138+
let updatedURL = resURL.replace(regEx.commitHash, `$1${resLatestCommitHash}`) // update hash
139139
if (!await isValidResource(updatedURL)) continue // to next resource
140140

141141
// Generate/compare/update SRI hash
142142
console.log(`${ !log.endedWithLineBreak ? '\n' : '' }Generating SRI (SHA-256) hash for ${resName}...`)
143143
const newSRIhash = await generateSRIhash(updatedURL)
144-
if (rePatterns.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
144+
if (regEx.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
145145
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
146146
continue // ...so skip resource
147147
}
148-
updatedURL = updatedURL.replace(rePatterns.sriHash, newSRIhash) // update hash
148+
updatedURL = updatedURL.replace(regEx.sriHash, newSRIhash) // update hash
149149
if (!await isValidResource(updatedURL)) continue // to next resource
150150

151151
// Write updated URL to userscript

chatgpt-widescreen/utils/bump/resources.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
br = '\x1b[1;91m' // bright red
2323

2424
// Init REGEX
25-
const rePatterns = {
25+
const regEx = {
2626
resName: /[^/]+\/(?:css|dist)?\/?[^/]+\.(?:css|js)(?=[?#]|$)/,
2727
jsURL: /^\/\/ @require\s+(https:\/\/cdn\.jsdelivr\.net\/gh\/.+)$/,
2828
commitHash: /(@|\?v=)([^/#]+)/, sriHash: /[^#]+$/
@@ -101,7 +101,7 @@
101101
// Collect resourcs
102102
log.working('\nCollecting resources...\n')
103103
const userJScontent = fs.readFileSync(userJSfilePath, 'utf-8'),
104-
reResURL = new RegExp(rePatterns.jsURL.source, 'gm'),
104+
reResURL = new RegExp(regEx.jsURL.source, 'gm'),
105105
resURLs = [...userJScontent.matchAll(reResURL)].map(match => match[1] || match[2])
106106
log.success(`${resURLs.length} potentially bumpable resource(s) found.`)
107107

@@ -121,27 +121,27 @@
121121
// Process each resource
122122
for (const resURL of resURLs) {
123123
if (!await isValidResource(resURL)) continue // to next resource
124-
const resName = rePatterns.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
124+
const resName = regEx.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
125125

126126
// Compare/update commit hash
127127
let resLatestCommitHash = latestCommitHashes[resURL.includes(repoName) ? 'chromium' : 'aiweb']
128128
if (resLatestCommitHash.startsWith( // compare hashes
129-
rePatterns.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
129+
regEx.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
130130
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
131131
continue // ...so skip resource
132132
}
133133
resLatestCommitHash = resLatestCommitHash.substring(0, 7) // abbr it
134-
let updatedURL = resURL.replace(rePatterns.commitHash, `$1${resLatestCommitHash}`) // update hash
134+
let updatedURL = resURL.replace(regEx.commitHash, `$1${resLatestCommitHash}`) // update hash
135135
if (!await isValidResource(updatedURL)) continue // to next resource
136136

137137
// Generate/compare/update SRI hash
138138
console.log(`${ !log.endedWithLineBreak ? '\n' : '' }Generating SRI (SHA-256) hash for ${resName}...`)
139139
const newSRIhash = await generateSRIhash(updatedURL)
140-
if (rePatterns.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
140+
if (regEx.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
141141
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
142142
continue // ...so skip resource
143143
}
144-
updatedURL = updatedURL.replace(rePatterns.sriHash, newSRIhash) // update hash
144+
updatedURL = updatedURL.replace(regEx.sriHash, newSRIhash) // update hash
145145
if (!await isValidResource(updatedURL)) continue // to next resource
146146

147147
// Write updated URL to userscript

duckduckgpt/utils/bump/resources.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
br = '\x1b[1;91m' // bright red
2323

2424
// Init REGEX
25-
const rePatterns = {
25+
const regEx = {
2626
resName: /[^/]+\/(?:css|dist)?\/?[^/]+\.(?:css|js)(?=[?#]|$)/,
2727
jsURL: /^\/\/ @require\s+(https:\/\/cdn\.jsdelivr\.net\/gh\/.+)$/,
2828
commitHash: /(@|\?v=)([^/#]+)/, sriHash: /[^#]+$/
@@ -101,7 +101,7 @@
101101
// Collect resourcs
102102
log.working('\nCollecting resources...\n')
103103
const userJScontent = fs.readFileSync(userJSfilePath, 'utf-8'),
104-
reResURL = new RegExp(rePatterns.jsURL.source, 'gm'),
104+
reResURL = new RegExp(regEx.jsURL.source, 'gm'),
105105
resURLs = [...userJScontent.matchAll(reResURL)].map(match => match[1] || match[2])
106106
log.success(`${resURLs.length} potentially bumpable resource(s) found.`)
107107

@@ -121,27 +121,27 @@
121121
// Process each resource
122122
for (const resURL of resURLs) {
123123
if (!await isValidResource(resURL)) continue // to next resource
124-
const resName = rePatterns.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
124+
const resName = regEx.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
125125

126126
// Compare/update commit hash
127127
let resLatestCommitHash = latestCommitHashes[resURL.includes(repoName) ? 'chromium' : 'aiweb']
128128
if (resLatestCommitHash.startsWith( // compare hashes
129-
rePatterns.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
129+
regEx.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
130130
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
131131
continue // ...so skip resource
132132
}
133133
resLatestCommitHash = resLatestCommitHash.substring(0, 7) // abbr it
134-
let updatedURL = resURL.replace(rePatterns.commitHash, `$1${resLatestCommitHash}`) // update hash
134+
let updatedURL = resURL.replace(regEx.commitHash, `$1${resLatestCommitHash}`) // update hash
135135
if (!await isValidResource(updatedURL)) continue // to next resource
136136

137137
// Generate/compare/update SRI hash
138138
console.log(`${ !log.endedWithLineBreak ? '\n' : '' }Generating SRI (SHA-256) hash for ${resName}...`)
139139
const newSRIhash = await generateSRIhash(updatedURL)
140-
if (rePatterns.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
140+
if (regEx.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
141141
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
142142
continue // ...so skip resource
143143
}
144-
updatedURL = updatedURL.replace(rePatterns.sriHash, newSRIhash) // update hash
144+
updatedURL = updatedURL.replace(regEx.sriHash, newSRIhash) // update hash
145145
if (!await isValidResource(updatedURL)) continue // to next resource
146146

147147
// Write updated URL to userscript

googlegpt/utils/bump/resources.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
br = '\x1b[1;91m' // bright red
2323

2424
// Init REGEX
25-
const rePatterns = {
25+
const regEx = {
2626
resName: /[^/]+\/(?:css|dist)?\/?[^/]+\.(?:css|js)(?=[?#]|$)/,
2727
jsURL: /^\/\/ @require\s+(https:\/\/cdn\.jsdelivr\.net\/gh\/.+)$/,
2828
commitHash: /(@|\?v=)([^/#]+)/, sriHash: /[^#]+$/
@@ -101,7 +101,7 @@
101101
// Collect resourcs
102102
log.working('\nCollecting resources...\n')
103103
const userJScontent = fs.readFileSync(userJSfilePath, 'utf-8'),
104-
reResURL = new RegExp(rePatterns.jsURL.source, 'gm'),
104+
reResURL = new RegExp(regEx.jsURL.source, 'gm'),
105105
resURLs = [...userJScontent.matchAll(reResURL)].map(match => match[1] || match[2])
106106
log.success(`${resURLs.length} potentially bumpable resource(s) found.`)
107107

@@ -121,27 +121,27 @@
121121
// Process each resource
122122
for (const resURL of resURLs) {
123123
if (!await isValidResource(resURL)) continue // to next resource
124-
const resName = rePatterns.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
124+
const resName = regEx.resName.exec(resURL)?.[0] || 'resource' // dir/filename for logs
125125

126126
// Compare/update commit hash
127127
let resLatestCommitHash = latestCommitHashes[resURL.includes(repoName) ? 'chromium' : 'aiweb']
128128
if (resLatestCommitHash.startsWith( // compare hashes
129-
rePatterns.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
129+
regEx.commitHash.exec(resURL)?.[2] || '')) { // commit hash didn't change...
130130
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
131131
continue // ...so skip resource
132132
}
133133
resLatestCommitHash = resLatestCommitHash.substring(0, 7) // abbr it
134-
let updatedURL = resURL.replace(rePatterns.commitHash, `$1${resLatestCommitHash}`) // update hash
134+
let updatedURL = resURL.replace(regEx.commitHash, `$1${resLatestCommitHash}`) // update hash
135135
if (!await isValidResource(updatedURL)) continue // to next resource
136136

137137
// Generate/compare/update SRI hash
138138
console.log(`${ !log.endedWithLineBreak ? '\n' : '' }Generating SRI (SHA-256) hash for ${resName}...`)
139139
const newSRIhash = await generateSRIhash(updatedURL)
140-
if (rePatterns.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
140+
if (regEx.sriHash.exec(resURL)?.[0] == newSRIhash) { // SRI hash didn't change
141141
console.log(`${resName} already up-to-date!`) ; log.endedWithLineBreak = false
142142
continue // ...so skip resource
143143
}
144-
updatedURL = updatedURL.replace(rePatterns.sriHash, newSRIhash) // update hash
144+
updatedURL = updatedURL.replace(regEx.sriHash, newSRIhash) // update hash
145145
if (!await isValidResource(updatedURL)) continue // to next resource
146146

147147
// Write updated URL to userscript

0 commit comments

Comments
 (0)