MCPcopy Index your code
hub / github.com/hoothin/UserScripts / initRules

Function initRules

Pagetual/pagetual.user.js:10751–11054  ·  view source on GitHub ↗
(callback)

Source from the content-addressed store, hash-verified

10749
10750 let pageReady = false;
10751 async function initRules(callback) {
10752 charset = (document.characterSet || document.charset || document.inputEncoding);
10753 let equiv = document.querySelector('[http-equiv="Content-Type"]');
10754 if (equiv && equiv.content) {
10755 let innerCharSet = equiv.content.match(/charset\=([^;]+)/);
10756 if (!innerCharSet) {
10757 charsetValid = false;
10758 } else if (innerCharSet[1].replace("-", "").toLowerCase() != charset.replace("-", "").toLowerCase()) {
10759 charsetValid = false;
10760 }
10761 } else charsetValid = false;
10762 storage.getItem("rulesData", data => {
10763 /*0 wedata格式,1 pagetual格式*/
10764 ruleUrls = [{
10765 id: 1,
10766 url: data && data.wedata2github ? wedataMirrorRulesUrl : wedataRulesUrl,
10767 type: 0
10768 }];
10769 if (data) {
10770 rulesData = data;
10771 if (data.urls) ruleUrls = ruleUrls.concat(data.urls);
10772 if (data.sort) {
10773 let urls = [];
10774 data.sort.forEach(id => {
10775 for (let s = 0; s < ruleUrls.length; s++) {
10776 if (id == ruleUrls[s].id) {
10777 urls.push(ruleUrls[s]);
10778 break;
10779 }
10780 }
10781 });
10782 ruleUrls = urls;
10783 }
10784 }
10785 if (rulesData.lang) {
10786 setLang(rulesData.lang);
10787 if (langName === 'zh-CN') {
10788 configPage.unshift(cnConfigPage);
10789 }
10790 }
10791 if (rulesData.firstRun && storage.supportCrossSave()) {
10792 rulesData.firstRun = false;
10793 storage.setItem("rulesData", rulesData);
10794 setTimeout(() => {
10795 storage.getItem("rulesData", data => {
10796 if (data.firstRun === false) {
10797 _GM_openInTab(firstRunPage, {active: true});
10798 }
10799 });
10800 }, 100);
10801 }
10802 _GM_registerMenuCommand(i18n("configure"), () => {
10803 if (window.top == window.self) {
10804 _GM_openInTab(rulesData.configPage || configPage[0], {active: true});
10805 }
10806 });
10807 if (rulesData.blacklist && rulesData.blacklist.length > 0) {
10808 let href = location.href.slice(0, 500);

Callers 2

domReadyFunction · 0.85
initFunction · 0.85

Calls 15

setLoadingDivFunction · 0.85
getListDataFunction · 0.85
getDataFunction · 0.85
showTipsFunction · 0.85
listenUrlFunction · 0.85
updateRulesFunction · 0.85
debugFunction · 0.85
changeStopFunction · 0.85
setListDataFunction · 0.85
startAutoScrollFunction · 0.85
initSavedRulesMethod · 0.80
removeMethod · 0.80

Tested by

no test coverage detected