MCPcopy
hub / github.com/zxlie/FeHelper / buildFilenameFromUrl

Function buildFilenameFromUrl

apps/screenshot/content-script.js:1192–1206  ·  view source on GitHub ↗

* 根据网页URL生成默认文件名 * @returns {string} - 生成的文件名

()

Source from the content-addressed store, hash-verified

1190 * @returns {string} - 生成的文件名
1191 */
1192 function buildFilenameFromUrl() {
1193 let name = location.href.split('?')[0].split('#')[0];
1194 if (name) {
1195 name = name
1196 .replace(/^https?:\/\//, '')
1197 .replace(/[^A-z0-9]+/g, '-')
1198 .replace(/-+/g, '-')
1199 .replace(/^[_\-]+/, '')
1200 .replace(/[_\-]+$/, '');
1201 name = '-' + name;
1202 } else {
1203 name = '';
1204 }
1205 return 'fehelper' + name + '-' + Date.now() + '.png';
1206 }
1207
1208 // 在截图失败的回调中,确保错误信息被正确记录,并释放资源
1209 function captureFailureHandler(reason) {

Callers 3

content-script.jsFile · 0.85
captureVisibleFunction · 0.85
finishCaptureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected