Skip to content

Commit

Permalink
Merge pull request #41 from FW27623/pages
Browse files Browse the repository at this point in the history
将JsDelivr设为备用方案,Ghproxy为首选方案
  • Loading branch information
FW27623 authored Sep 3, 2023
2 parents fc4f6d1 + 00fc441 commit 330599c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
17 changes: 17 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,21 @@ a {
::selection {
background-color: var(--secondary-color);
color: var(--text-color);
}
button.backup {
margin-left: 10px;
background-color: #f2f2f2;
border: none;
color: #333;
padding: 5px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
cursor: pointer;
border-radius: 3px;
}

button.backup:hover {
background-color: #e6e6e6;
}
18 changes: 15 additions & 3 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
function loadJSON(type) {
var urls = {
'basic': 'https://cdn.jsdelivr.net/gh/Snoopy1866/LiTiaotiao-Custom-Rules@latest/BasicRules.json',
'all': 'https://cdn.jsdelivr.net/gh/Snoopy1866/LiTiaotiao-Custom-Rules@latest/AllRules.json'
'basic': 'https://ghproxy.com/https://raw.githubusercontent.com/Snoopy1866/LiTiaotiao-Custom-Rules/main/BasicRules.json',
'all': 'https://ghproxy.com/https://raw.githubusercontent.com/Snoopy1866/LiTiaotiao-Custom-Rules/main/AllRules.json',
'basic_backup': 'https://cdn.jsdelivr.net/gh/Snoopy1866/LiTiaotiao-Custom-Rules/BasicRules.json',
'all_backup': 'https://cdn.jsdelivr.net/gh/Snoopy1866/LiTiaotiao-Custom-Rules/AllRules.json'
};
var url = urls[type];
var ruleName = type === 'basic' ? '基础规则' : '全部规则';
var ruleName = type === 'basic' ? '基础规则' : type === 'all' ? '全部规则' : type === 'basic_backup' ? '基础规则备份' : '全部规则备份';

var ruleType = document.getElementById('rule-type');
ruleType.innerHTML = `<b>当前选择的是<span class="highlight">${ruleName}</span></b>`;
Expand Down Expand Up @@ -32,6 +34,16 @@ function loadJSON(type) {
document.getElementById('json-text').value = data;
});
}

if (type === 'basic' || type === 'all') {
var backupButton = document.createElement('button');
backupButton.innerHTML = type === 'basic' ? '基础规则(JsDelivr)' : '全部规则(JsDelivr))';
backupButton.className = 'backup';
backupButton.onclick = function() {
loadJSON(type + '_backup');
};
ruleType.appendChild(backupButton);
}
}

function copyText() {
Expand Down

0 comments on commit 330599c

Please sign in to comment.