Skip to content

Commit

Permalink
✨ feat(debugFuncs): add ghRepoProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
latedreamdev committed Aug 23, 2024
1 parent e611830 commit 5d9b7c9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
7 changes: 6 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,15 @@ <h2 class="page-title" al="config"></h2>
<mdui-slider class="inline-block searchable-prompt-length" name="searchable-prompt-length"
value="10" min="0" max="30"></mdui-slider>
</label>
<label visibleInDebugMode>
<label al="debugFuncs" debugFuncs>debugFuncs</label>
<label debugFuncs>
<input id="clickEffect" type="checkbox" onclick="this.disabled = true;">
<text al="clickEffect">clickEffect</text>
</label>
<label debugFuncs>
<input id="githubRepoProxy" type="checkbox" onclick="">
<text al="githubRepoProxy">githubRepoProxy</text>
</label>
</div>
<div class="ellipsis">
<h2 al="ellipsis"></h2>
Expand Down
1 change: 1 addition & 0 deletions scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ let notificationCount = '';
let visibility = true;

const downloadMirrorUrl = 'https://ghproxy.cn/<T>';
const ghRepoMirrorUrl = '';

const downloadSVG = '<span class="svg right"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M320 336h76c55 0 100-21.21 100-75.6s-53-73.47-96-75.6C391.11 99.74 329 48 256 48c-69 0-113.44 45.79-128 91.2-60 5.7-112 35.88-112 98.4S70 336 136 336h56M192 400.1l64 63.9 64-63.9M256 224v224.03" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="56"></path></svg></span>';
const downloadMirror = ((url) => $('.github-proxy').is(':checked') && String(url).startsWith('https://github.com/') ? downloadMirrorUrl.replace('<T>', url) : url); // 针对大陆地区 | for Chinese Mainland
Expand Down
17 changes: 16 additions & 1 deletion scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,26 @@ $(document).ready(() => {
.then(console.log('[debug] clickEffect is now enabled!\nif you want to disable it pls refresh the page.'))
.catch(e => console.error(`[debug] ${e}`)); // 打开了就没有退路了awa 除非刷新页面awa
});
// githubRepoProxy
$('#githubRepoProxy').change(() => {
const proxy = ghRepoMirrorUrl || 'https://www.jsdelivr.com/package/gh';
if ($('#githubRepoProxy')[0].checked) {
try {$('a').each(function() {
if (this.href && this.href.startsWith('https://github.com'))
this.href = this.href.replace('https://github.com', proxy);
})} catch(e) {console.error(e)}
} else {
try {$('a').each(function() {
if (this.href && this.href.startsWith(proxy))
this.href = this.href.replace(proxy, 'https://github.com');
})} catch(e) {console.error(e)}
}
});
});


// 调试模式 (Debug Mode)
const debugCallback = (e = $('[visibleInDebugMode]')) => (debug.mode ? e.show() : e.hide());
const debugCallback = (e = $('[debugFuncs]')) => (debug.mode ? e.show() : e.hide());
const debugChange = ((object) => {
const handler = {
defineProperty: (target, property, descriptor) => {
Expand Down

0 comments on commit 5d9b7c9

Please sign in to comment.