|
@@ -221,23 +221,23 @@ if ("{{.PublishTimeCss}}" != "") {//发布时间
|
|
|
if (tmp) ret["publishTime"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
}
|
|
|
if ("{{.ContentCss}}" != "") {//正文内容
|
|
|
- tmp = document.querySelector("{{.ContentCss}}") || document.querySelector("第二套CSS选择器,请修改")
|
|
|
- if (tmp) {
|
|
|
- ret["content"] = tmp.innerText
|
|
|
- ret["contentHtml"] = tmp.innerHTML
|
|
|
- var patchContent = false
|
|
|
- //处理详情页中的大图,大图作为附件使用
|
|
|
- const images = tmp.querySelectorAll("img");
|
|
|
- images.forEach((img, i) => {
|
|
|
- if (img.width > 300) {
|
|
|
- patchContent = true
|
|
|
- const a = document.createElement("a");
|
|
|
- a.href = img.src;
|
|
|
- a.innerText = img.src;
|
|
|
- tmp.appendChild(a);
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ tmp = document.querySelector("{{.ContentCss}}") || document.querySelector("第二套CSS选择器,请修改")
|
|
|
+ if (tmp) {
|
|
|
+ ret["content"] = tmp.innerText
|
|
|
+ ret["contentHtml"] = tmp.innerHTML
|
|
|
+ var patchContent = false
|
|
|
+ //处理详情页中的大图,大图作为附件使用
|
|
|
+ const images = tmp.querySelectorAll("img");
|
|
|
+ images.forEach((img, i) => {
|
|
|
+ if (img.width > 300) {
|
|
|
+ patchContent = true
|
|
|
+ const a = document.createElement("a");
|
|
|
+ a.href = img.src;
|
|
|
+ a.innerText = img.src;
|
|
|
+ tmp.appendChild(a);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
if("{{.AttachCss}}"!=""){//附件
|
|
|
tmp = document.querySelectorAll("{{.AttachCss}} a")
|
|
@@ -270,51 +270,51 @@ ret
|
|
|
var tmp = null
|
|
|
|
|
|
if ("{{.TitleCss}}" != "") {//标题
|
|
|
- tmp = document.querySelector("{{.TitleCss}}") || document.querySelector("#activity-name")
|
|
|
- if (tmp) ret["title"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
+ tmp = document.querySelector("{{.TitleCss}}") || document.querySelector("#activity-name")
|
|
|
+ if (tmp) ret["title"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
}
|
|
|
if ("{{.PublishUnitCss}}" != "") {//采购单位
|
|
|
- tmp = document.querySelector("{{.PublishUnitCss}}") || document.querySelector("#js_name")
|
|
|
- if (tmp) ret["publishUnit"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
+ tmp = document.querySelector("{{.PublishUnitCss}}") || document.querySelector("#js_name")
|
|
|
+ if (tmp) ret["publishUnit"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
}
|
|
|
if ("{{.PublishTimeCss}}" != "") {//发布时间
|
|
|
- tmp = document.querySelector("{{.PublishTimeCss}}") || document.querySelector("#publish_time")
|
|
|
- if (tmp) ret["publishTime"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
+ tmp = document.querySelector("{{.PublishTimeCss}}") || document.querySelector("#publish_time")
|
|
|
+ if (tmp) ret["publishTime"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
}
|
|
|
if ("{{.ContentCss}}" != "") {//正文内容
|
|
|
- tmp = document.querySelector("{{.ContentCss}}") || document.querySelector("#js_content")
|
|
|
- if (tmp) {
|
|
|
- ret["content"] = tmp.innerText
|
|
|
- ret["contentHtml"] = tmp.innerHTML
|
|
|
- var patchContent = false
|
|
|
- //处理详情页中的大图,大图作为附件使用
|
|
|
- const images = tmp.querySelectorAll("img");
|
|
|
- images.forEach((img, i) => {
|
|
|
- if (img.width > 300) {
|
|
|
- patchContent = true
|
|
|
- const a = document.createElement("a");
|
|
|
- a.href = img.src;
|
|
|
- a.innerText = img.src;
|
|
|
- tmp.appendChild(a);
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ tmp = document.querySelector("{{.ContentCss}}") || document.querySelector("#js_content")
|
|
|
+ if (tmp) {
|
|
|
+ ret["content"] = tmp.innerText
|
|
|
+ ret["contentHtml"] = tmp.innerHTML
|
|
|
+ var patchContent = false
|
|
|
+ //处理详情页中的大图,大图作为附件使用
|
|
|
+ const images = tmp.querySelectorAll("img");
|
|
|
+ images.forEach((img, i) => {
|
|
|
+ if (img.width > 300) {
|
|
|
+ patchContent = true
|
|
|
+ const a = document.createElement("a");
|
|
|
+ a.href = img.src;
|
|
|
+ a.innerText = img.src;
|
|
|
+ tmp.appendChild(a);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
if("{{.AttachCss}}"!=""){//附件
|
|
|
- tmp = document.querySelectorAll("{{.AttachCss}} a")
|
|
|
- let attach=[]
|
|
|
- if(tmp){
|
|
|
- tmp.forEach((v,i)=>{
|
|
|
- attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
|
- })
|
|
|
- }
|
|
|
- tmp = document.querySelectorAll("#js_content a")
|
|
|
- if(tmp){
|
|
|
- tmp.forEach((v,i)=>{
|
|
|
- attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
|
- })
|
|
|
- }
|
|
|
- ret["attachLinks"]=attach
|
|
|
+ tmp = document.querySelectorAll("{{.AttachCss}} a")
|
|
|
+ let attach=[]
|
|
|
+ if(tmp){
|
|
|
+ tmp.forEach((v,i)=>{
|
|
|
+ attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
|
+ })
|
|
|
+ }
|
|
|
+ tmp = document.querySelectorAll("#js_content a")
|
|
|
+ if(tmp){
|
|
|
+ tmp.forEach((v,i)=>{
|
|
|
+ attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ret["attachLinks"]=attach
|
|
|
}
|
|
|
//检查中文字符个数,少于20,修正正文内容
|
|
|
let regex = /[\\u4e00-\\u9fa5]/g;
|
|
@@ -393,51 +393,115 @@ var ret = {}
|
|
|
var tmp = null
|
|
|
|
|
|
if ("{{.TitleCss}}" != "") {//标题
|
|
|
-tmp = document.querySelector("{{.TitleCss}}")
|
|
|
-if (tmp) ret["title"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
+ tmp = document.querySelector("{{.TitleCss}}")
|
|
|
+ if (tmp) ret["title"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
}
|
|
|
if ("{{.PublishUnitCss}}" != "") {//采购单位
|
|
|
-tmp = document.querySelector("{{.PublishUnitCss}}")
|
|
|
-if (tmp) ret["publishUnit"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
+ tmp = document.querySelector("{{.PublishUnitCss}}")
|
|
|
+ if (tmp) ret["publishUnit"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
}
|
|
|
if ("{{.PublishTimeCss}}" != "") {//发布时间
|
|
|
-tmp = document.querySelector("{{.PublishTimeCss}}")
|
|
|
-if (tmp) {
|
|
|
- // 格式:2024/01/05 2024-01-05 2024年01月05日 15:01:01 (仅时间,可以自己修改)
|
|
|
- var regTpl = ["(\\\\d{4}/\\\\d{1,2}/\\\\d{1,2})","(\\\\d{4}-\\\\d{1,2}-\\\\d{1,2})","(\\\\d{4}年\\\\d{1,2}月\\\\d{1,2}日)","\\\\d{1,2}:\\\\d{1,2}:\\\\d{1,2})"]
|
|
|
- //TODO 重点要修改这里的regTpl 索引号,也可以自己修改设置正则表达式
|
|
|
- var reg = new RegExp(regTpl[0])
|
|
|
- tmp = tmp.innerText.match(reg)
|
|
|
- if(tmp && tmp.length>1)ret["publishTime"] = tmp[1]
|
|
|
+ tmp = document.querySelector("{{.PublishTimeCss}}")
|
|
|
+ if (tmp) {
|
|
|
+ // 格式:2024/01/05 2024-01-05 2024年01月05日 15:01:01 (仅时间,可以自己修改)
|
|
|
+ var regTpl = ["(\\\\d{4}/\\\\d{1,2}/\\\\d{1,2})","(\\\\d{4}-\\\\d{1,2}-\\\\d{1,2})","(\\\\d{4}年\\\\d{1,2}月\\\\d{1,2}日)","\\\\d{1,2}:\\\\d{1,2}:\\\\d{1,2})"]
|
|
|
+ //TODO 重点要修改这里的regTpl 索引号,也可以自己修改设置正则表达式
|
|
|
+ var reg = new RegExp(regTpl[0])
|
|
|
+ tmp = tmp.innerText.match(reg)
|
|
|
+ if(tmp && tmp.length>1)ret["publishTime"] = tmp[1]
|
|
|
}
|
|
|
}
|
|
|
if ("{{.ContentCss}}" != "") {//正文内容
|
|
|
-tmp = document.querySelector("{{.ContentCss}}")
|
|
|
-if (tmp) {
|
|
|
-ret["content"] = tmp.innerText
|
|
|
-ret["contentHtml"] = tmp.innerHTML
|
|
|
-var patchContent = false
|
|
|
-//处理详情页中的大图,大图作为附件使用
|
|
|
-const images = tmp.querySelectorAll("img");
|
|
|
-images.forEach((img, i) => {
|
|
|
- if (img.width > 300) {
|
|
|
- patchContent = true
|
|
|
- const a = document.createElement("a");
|
|
|
- a.href = img.src;
|
|
|
- a.innerText = img.src;
|
|
|
- tmp.appendChild(a);
|
|
|
- }
|
|
|
-})
|
|
|
+ tmp = document.querySelector("{{.ContentCss}}")
|
|
|
+ if (tmp) {
|
|
|
+ ret["content"] = tmp.innerText
|
|
|
+ ret["contentHtml"] = tmp.innerHTML
|
|
|
+ var patchContent = false
|
|
|
+ //处理详情页中的大图,大图作为附件使用
|
|
|
+ const images = tmp.querySelectorAll("img");
|
|
|
+ images.forEach((img, i) => {
|
|
|
+ if (img.width > 300) {
|
|
|
+ patchContent = true
|
|
|
+ const a = document.createElement("a");
|
|
|
+ a.href = img.src;
|
|
|
+ a.innerText = img.src;
|
|
|
+ tmp.appendChild(a);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
+if("{{.AttachCss}}"!=""){//附件
|
|
|
+ tmp = document.querySelectorAll("{{.AttachCss}} a")
|
|
|
+ let attach=[]
|
|
|
+ if(tmp){
|
|
|
+ tmp.forEach((v,i)=>{
|
|
|
+ attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ret["attachLinks"]=attach
|
|
|
+}
|
|
|
+//检查中文字符个数,少于20,修正正文内容
|
|
|
+let regex = /[\\u4e00-\\u9fa5]/g;
|
|
|
+let chineseCharacters = ret["content"]?ret["content"].match(regex):[];
|
|
|
+let chineseCharactersLen=chineseCharacters ? chineseCharacters.length : 0;
|
|
|
+if (chineseCharactersLen < 20 && ret["attachLinks"] && ret["attachLinks"].length>0) ret["content"] = '详情请访问原网页!'
|
|
|
+ret
|
|
|
+`}, {
|
|
|
+ "name": "模版6",
|
|
|
+ "tooltip": "基础模板扩展,正文、附件区域,都需要找附件",
|
|
|
+ "code": `
|
|
|
+var ret = {}
|
|
|
+var tmp = null
|
|
|
+
|
|
|
+if ("{{.TitleCss}}" != "") {//标题
|
|
|
+ tmp = document.querySelector("{{.TitleCss}}")
|
|
|
+ if (tmp) ret["title"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
+}
|
|
|
+if ("{{.PublishUnitCss}}" != "") {//采购单位
|
|
|
+ tmp = document.querySelector("{{.PublishUnitCss}}")
|
|
|
+ if (tmp) ret["publishUnit"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
+}
|
|
|
+if ("{{.PublishTimeCss}}" != "") {//发布时间
|
|
|
+ tmp = document.querySelector("{{.PublishTimeCss}}")
|
|
|
+ if (tmp) ret["publishTime"] = tmp.getAttribute("title") || tmp.innerText
|
|
|
+}
|
|
|
+if ("{{.ContentCss}}" != "") {//正文内容
|
|
|
+ tmp = document.querySelector("{{.ContentCss}}")
|
|
|
+ if (tmp) {
|
|
|
+ ret["content"] = tmp.innerText
|
|
|
+ ret["contentHtml"] = tmp.innerHTML
|
|
|
+ var patchContent = false
|
|
|
+ //处理详情页中的大图,大图作为附件使用
|
|
|
+ const images = tmp.querySelectorAll("img");
|
|
|
+ images.forEach((img, i) => {
|
|
|
+ if (img.width > 300) {
|
|
|
+ patchContent = true
|
|
|
+ const a = document.createElement("a");
|
|
|
+ a.href = img.src;
|
|
|
+ a.innerText = img.src;
|
|
|
+ tmp.appendChild(a);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
if("{{.AttachCss}}"!=""){//附件
|
|
|
-tmp = document.querySelectorAll("{{.AttachCss}} a")
|
|
|
-let attach=[]
|
|
|
+ //附件区域检查
|
|
|
+ tmp = document.querySelectorAll("{{.AttachCss}} a")
|
|
|
+ let attach=[]
|
|
|
+ if(tmp){
|
|
|
+ tmp.forEach((v,i)=>{
|
|
|
+ attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
|
+ })
|
|
|
+}
|
|
|
+//正文区域附件检查
|
|
|
+tmp = document.querySelectorAll("{{.ContentCss}} a")
|
|
|
if(tmp){
|
|
|
tmp.forEach((v,i)=>{
|
|
|
attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
|
})
|
|
|
}
|
|
|
+//附件过滤
|
|
|
+attch = attach.filter((item)=>item.href && item.href.startsWith('http'))
|
|
|
ret["attachLinks"]=attach
|
|
|
}
|
|
|
//检查中文字符个数,少于20,修正正文内容
|
|
@@ -446,7 +510,8 @@ let chineseCharacters = ret["content"]?ret["content"].match(regex):[];
|
|
|
let chineseCharactersLen=chineseCharacters ? chineseCharacters.length : 0;
|
|
|
if (chineseCharactersLen < 20 && ret["attachLinks"] && ret["attachLinks"].length>0) ret["content"] = '详情请访问原网页!'
|
|
|
ret
|
|
|
-`},
|
|
|
+`,
|
|
|
+ },
|
|
|
],
|
|
|
|
|
|
AttachJsCode: `
|
|
@@ -486,7 +551,7 @@ document.querySelectorAll("{{.ListNextPageCss}}").forEach(link=>{
|
|
|
"tooltip": "选择器匹配多个 翻页链接/按钮,可根据检测是否包含子对象匹配",
|
|
|
"code": `
|
|
|
document.querySelectorAll("{{.ListNextPageCss}}").forEach(link=>{
|
|
|
- if(link.querySelector("自对象CSS选择器,请修改"))link.click();
|
|
|
+ if(link.querySelector("子对象CSS选择器,请修改"))link.click();
|
|
|
})
|
|
|
""
|
|
|
`,
|
|
@@ -517,5 +582,41 @@ window.location=href
|
|
|
`,
|
|
|
},
|
|
|
],
|
|
|
-
|
|
|
+ //初始化代码集合
|
|
|
+ InitListPageJsCodes: [
|
|
|
+ {
|
|
|
+ "name": "模版1",
|
|
|
+ "tooltip": "页面跳转",
|
|
|
+ "code": `
|
|
|
+window.location=''
|
|
|
+''
|
|
|
+ `,
|
|
|
+ }, {
|
|
|
+ "name": "模版2",
|
|
|
+ "tooltip": "点击唯一元素",
|
|
|
+ "code": `
|
|
|
+var link=document.querySelector("CSS选择器");
|
|
|
+if(link)link.click();
|
|
|
+""
|
|
|
+ `,
|
|
|
+ }, {
|
|
|
+ "name": "模版3",
|
|
|
+ "tooltip": "点击需要文本过滤",
|
|
|
+ "code": `
|
|
|
+document.querySelectorAll("CSS选择器").forEach(link=>{
|
|
|
+ if(link.innerText==="下一页")link.click();
|
|
|
+})
|
|
|
+""
|
|
|
+ `,
|
|
|
+ }, {
|
|
|
+ "name": "模版4",
|
|
|
+ "tooltip": "点击需要子元素过滤",
|
|
|
+ "code": `
|
|
|
+document.querySelectorAll("CSS选择器").forEach(link=>{
|
|
|
+ if(link.querySelector("子对象CSS选择器,请修改"))link.click();
|
|
|
+})
|
|
|
+""
|
|
|
+ `,
|
|
|
+ },
|
|
|
+ ],
|
|
|
}
|