(detail, noFill)
| 9169 | } |
| 9170 | |
| 9171 | getTempRule(detail, noFill) { |
| 9172 | if (this.tempRule.value) { |
| 9173 | try { |
| 9174 | this.editTemp = JSON.parse(this.tempRule.value); |
| 9175 | } catch (e) { |
| 9176 | this.editTemp = null; |
| 9177 | if (detail) { |
| 9178 | let pos = e && e.message && e.message.match(/position (\d+)/); |
| 9179 | if (pos) { |
| 9180 | pos = parseInt(pos[1]); |
| 9181 | this.tempRule.value = this.tempRule.value.slice(0, pos) + "➡️" + this.tempRule.value.slice(pos); |
| 9182 | } |
| 9183 | showTips(i18n("errorJson")); |
| 9184 | return null; |
| 9185 | } |
| 9186 | } |
| 9187 | } |
| 9188 | if (!this.editTemp) { |
| 9189 | if (ruleParser.curSiteRule.url && !ruleParser.curSiteRule.smart) { |
| 9190 | this.editTemp = ruleParser.curSiteRule; |
| 9191 | } else { |
| 9192 | this.editTemp = { |
| 9193 | name: document.title, |
| 9194 | url: "^" + (location.origin + location.pathname).replace(/[^\/]*$/, "").replace(/^https?/, "https?").replace(/\./g, "\\."), |
| 9195 | example: location.href |
| 9196 | }; |
| 9197 | if (author) this.editTemp.author = author; |
| 9198 | } |
| 9199 | delete this.editTemp.from; |
| 9200 | delete this.editTemp.type; |
| 9201 | delete this.editTemp.updatedAt; |
| 9202 | } |
| 9203 | if (!noFill && this.selectorInput.value && (!this.frame.classList.contains("showDetail") || !this.editTemp || !this.editTemp.pageElement)) { |
| 9204 | if (this.foundEle) { |
| 9205 | if (this.foundEle.length === 1) { |
| 9206 | let foundEleRect = this.foundEle[0].getBoundingClientRect(); |
| 9207 | if (foundEleRect.height < 100) { |
| 9208 | showTips("Next Link", "", 500); |
| 9209 | this.editTemp.nextLink = this.selectorInput.value; |
| 9210 | return this.editTemp; |
| 9211 | } |
| 9212 | } else if (this.foundEle.length <= 3) { |
| 9213 | let foundEleRect = this.foundEle[0].getBoundingClientRect(); |
| 9214 | if (foundEleRect.height < 50) { |
| 9215 | showTips("Next Link", "", 500); |
| 9216 | this.editTemp.nextLink = this.selectorInput.value; |
| 9217 | return this.editTemp; |
| 9218 | } |
| 9219 | } |
| 9220 | } |
| 9221 | showTips("Page Element", "", 500); |
| 9222 | this.editTemp.pageElement = this.selectorInput.value; |
| 9223 | } |
| 9224 | return this.editTemp; |
| 9225 | } |
| 9226 | |
| 9227 | getTarget(ele) { |
| 9228 | while (ele.parentNode && (ele.offsetWidth === 0 || ele.offsetHeight === 0)) { |
no test coverage detected