()
| 1190 | } |
| 1191 | |
| 1192 | function pageRun(){ |
| 1193 | for(var x = 0; x < sitesArr.length; x++){ |
| 1194 | let offNode=$("<a></a>"); |
| 1195 | offNode.addClass('whx-a').css("position","absolute").css("margin-top","0px").css("margin-left","0px").attr("target","_blank"); |
| 1196 | let siteConfig=sitesArr[x]; |
| 1197 | offNode.css("background-color","#"+siteConfig.bgColor).attr("title",i18n(siteConfig.name) ).attr("href", siteConfig.url).attr("name", siteConfig.name); |
| 1198 | offNode.click(function(e){ |
| 1199 | offUrl=getRightUrl(offUrl); |
| 1200 | if(siteConfig.directUrl){ |
| 1201 | if(e.ctrlKey && e.shiftKey){ |
| 1202 | let linkRegExp=siteConfig.linkRegExp || /.*/; |
| 1203 | let aTags = $("a.whx-a-node").get(),urlArr=[]; |
| 1204 | for(let aTag of aTags){ |
| 1205 | aTag=nodeDict[aTag]; |
| 1206 | if(!aTag)continue; |
| 1207 | if(linkRegExp.test(aTag.href)){ |
| 1208 | let url=siteConfig.directUrl(getRightUrl(aTag.href), aTag); |
| 1209 | if(/^c:/.test(url)){ |
| 1210 | urlArr.push(url.replace(/^c:/i,"")); |
| 1211 | }else if(/^p:/.test(url)){ |
| 1212 | url=url.match(/p:(.*?)\?(.*?)(\$headers({.*}))?$/); |
| 1213 | if(!url)return; |
| 1214 | let postData=JSON.stringify(urlArgs(url[2])); |
| 1215 | let headers = url[4] ? JSON.parse(url[4]) : null; |
| 1216 | url=url[1]; |
| 1217 | _GM_xmlhttpRequest({ |
| 1218 | method: "POST", url: url, data: postData, headers: headers, |
| 1219 | onload: (d) => { |
| 1220 | _GM_notification(i18n("postOver")+d.statusText); |
| 1221 | }, |
| 1222 | onerror: (e) => { |
| 1223 | _GM_notification(i18n("postError")+(e.statusText||e.error)); |
| 1224 | }, |
| 1225 | ontimeout: (e) => { |
| 1226 | _GM_notification(i18n("postError")+(e.statusText||e.error)); |
| 1227 | } |
| 1228 | }); |
| 1229 | e.preventDefault(); |
| 1230 | }else if(url){ |
| 1231 | window.open(/:\/\//.test(url)?url:("http://"+url)); |
| 1232 | }else{ |
| 1233 | e.preventDefault(); |
| 1234 | } |
| 1235 | } |
| 1236 | } |
| 1237 | if(urlArr.length>0){ |
| 1238 | _GM_setClipboard(urlArr.join("\n")); |
| 1239 | _GM_notification(i18n("copyOver")); |
| 1240 | } |
| 1241 | }else{ |
| 1242 | let url=siteConfig.directUrl(offUrl, nodeDict[targetNode]); |
| 1243 | if(/^c:/.test(url)){ |
| 1244 | _GM_setClipboard(url.replace(/^c:/i,"")); |
| 1245 | _GM_notification(i18n("copyOver")); |
| 1246 | }else if(/^p:/.test(url)){ |
| 1247 | url=url.match(/p:(.*?)\?(.*?)(\$headers({.*}))?$/); |
| 1248 | if(!url)return; |
| 1249 | let postData=JSON.stringify(urlArgs(url[2])); |
no test coverage detected