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

Function searchByTime

Picviewer CE+/dist.user.js:25946–26037  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25944 var self = this, r = 0, urlChecked = false;
25945 self.rules=[];
25946 function searchByTime(){
25947 setTimeout(()=>{
25948 let end=r+20;
25949 end=end>siteInfo.length?siteInfo.length:end;
25950 for(;r<end;r++){
25951 let site=siteInfo[r];
25952 if (site.enabled != false && (!site.url || toRE(site.url).test(_URL))) {
25953 if (site.xhr) {
25954 site.xhr.after = src => {
25955 let newSrc = self.replaceByRule(src, site, true);
25956 if (Array.isArray(newSrc)) newSrc = newSrc[0];
25957 return newSrc && newSrc.length ? newSrc : src;
25958 };
25959 let reMatch = typeof site.xhr.url === "string" && site.xhr.url.match(/^\/(.*)\/(\w*)$/);
25960 if (reMatch) {
25961 site.xhr.url = toRE(reMatch[1], reMatch[2]);
25962 } else if (Array.isArray(site.xhr.url)) {
25963 let urlRe = toRE(site.xhr.url[0], "i");
25964 let urlParam = site.xhr.url[1];
25965 site.xhr.url = (a, p) => {
25966 if (!a || !a.href) return;
25967 if (urlRe.test(a.href)) {
25968 return a.href.replace(urlRe, urlParam);;
25969 }
25970 };
25971 }
25972 }
25973 if (site.url && !urlChecked) {
25974 urlChecked = true;
25975 if (site.css) {
25976 var style = _GM_addStyle(site.css);
25977 style.id = 'gm-picviewer-site-style';
25978 }
25979 if (site.lazyAttr) {
25980 self.lazyAttr = site.lazyAttr;
25981 }
25982 if (site.description) {
25983 self.description = site.description;
25984 }
25985 if (site.clickToOpen) {
25986 self.clickToOpen = site.clickToOpen;
25987 }
25988 if (site.ext) {
25989 self.ext = site.ext;
25990 }
25991 if (site.gallery) {
25992 let gallery = site.gallery;
25993 self.gallery = () => {
25994 if (typeof gallery === "string") {
25995 return document.querySelectorAll(gallery);
25996 } else {
25997 return gallery();
25998 }
25999 };
26000 }
26001 if (site.video) {
26002 let reMatch = typeof site.video === "string" && site.video.match(/^\/(.*)\/(\w*)$/);
26003 if (reMatch) {

Callers 3

initFunction · 0.70
searchByTimeMethod · 0.50
getRuleMethod · 0.50

Calls 1

toREFunction · 0.70

Tested by

no test coverage detected