diff --git a/content.js b/content.js index 7178735..6ca5e6c 100644 --- a/content.js +++ b/content.js @@ -1,6 +1,6 @@ class MessagingService { - async GetNodes(sender, callback) { + async GetHyperlinkNodes(sender, callback) { const a = this; const nodes = await document.body.getElementsByTagName("a"); let result = []; @@ -8,7 +8,7 @@ class MessagingService { for (let i=0; i": ">", + '"': """, + "'": "'", + }; + + let result = (htmlContent ?? "").replace("\r", "").replace("\n", "\\n").replace("\t", "\\t"); + result = result.replace(/[&<>"']/g, (char) => map[char]); + + return result; + } + } diff --git a/popup.dist.js b/popup.dist.js index 3891f7f..413e633 100644 --- a/popup.dist.js +++ b/popup.dist.js @@ -3,4 +3,4 @@ * Copyright 2024-2024 Ray Lam (https://www.hiimray.co.uk) * */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PejiInspektor=t():e.PejiInspektor=t()}(this,(()=>(()=>{var e={645:function(e){var t;t=()=>(()=>{var e={814:()=>{Array.isEmpty=function(e){return"array"!=Object.getDataType(e)||e.length<=0},Array.toFlatten=function(e,t,n){for(let r=0;r0&&Array.toFlatten(e[r][t],t,n)},Array.prototype.addRange=function(e){return null==e||e.forEach((e=>{this.push(e)})),this},Array.prototype.all=function(e,t){for(let n=0;n{t+=this.count(e.propName,e.value)})),t},Array.prototype.create=function(e,t){let n=[];for(let r=0;rt===n.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)))))},Array.prototype.flatten=function(e){let t=[];return Array.toFlatten(this,e,t),t},Array.prototype.get=function(e){return e<0||e>=this.length?"":this[e]},Array.prototype.index=function(e,t){const n=this.indexes(e,t);return n.length<=0?null:n[0]},Array.prototype.indexes=function(e,t){let n=[];for(let r=0;r=this.length?this.push(t):this.splice(e,0,t),this},Array.prototype.joinIfNotNullOrWhitespace=function(e){let t="";for(let n=0;nn[e]?1:0})),this},Array.prototype.orderByDesc=function(e){return this.sort((function(t,n){return t[e]n[e]?-1:0})),this},Array.prototype.remove=function(e){let t=[];for(let n=0;n=0;e--)this.removeAt(t[e]);return this},Array.prototype.removeAt=function(e){return e<0||e>=this.length||this.splice(e,1),this},Array.prototype.removeRange=function(e){for(let t=0;t{t=t.select(e.propName,e.value)})),t},Array.prototype.toList=function(e){let t=[];return this.forEach((n=>{null!=typeof n[e]&&t.push(n[e])})),t},Array.prototype.sortTree=function(e,t){this.orderBy(t);for(let n=0;n{Boolean.isFalse=function(e){return!!String.isNullOrUndefined(e)||e.toString().containsCI("false","f","y","0","x")},Boolean.isTrue=function(e){return!String.isNullOrUndefined(e)&&e.toString().containsCI("true","t","n","1","o")},Boolean.ifTrue=function(e,t,n){return Boolean.isTrue(e)?t:n}},579:()=>{Date.addDays=function(e,t){let n=new Date(e);return n.addDays(t),n},Date.addMonths=function(e,t){let n=new Date(e);return n.addMonths(t),n},Date.addYears=function(e,t){let n=new Date(e);return n.addYears(t),n},Date.max=function(e,t){return null==e?t:null==t?e:new Date(e)<=new Date(t)?new Date(t):new Date(e)},Date.min=function(e,t){return null==e?t:null==t?e:new Date(e)<=new Date(t)?new Date(e):new Date(t)},Date.diffDays=function(e,t){return Math.ceil((new Date(t).getTime()-new Date(e).getTime())/864e5)},Date.today=function(){let e=new Date;return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),e},Date.prototype.addDays=function(e){this.setDate(this.getDate()+parseInt(e))},Date.prototype.addMonths=function(e){this.setMonth(this.getMonth()+parseInt(e))},Date.prototype.addYears=function(e){this.setFullYear(this.getFullYear()+parseInt(e))},Date.prototype.toCString=function(e){let t=e;return t=t.replace("fffffff",this.getMilliseconds().toString().padStart(7,"0")),t=t.replace("ffffff",this.getMilliseconds().toString().padStart(6,"0")),t=t.replace("fffff",this.getMilliseconds().toString().padStart(5,"0")),t=t.replace("yyyy",this.getFullYear().toString().padStart(4,"0")),t=t.replace("MMMM","{1}"),t=t.replace("dddd","{2}"),t=t.replace("ffff",this.getMilliseconds().toString().padStart(4,"0")),t=t.replace("yyy",this.getFullYear().toString().padStart(3,"0")),t=t.replace("MMM","{3}"),t=t.replace("ddd","{4}"),t=t.replace("fff",this.getMilliseconds().toString().padStart(3,"0")),t=t.replace("zzz",""),t=t.replace("yy",this.getFullYear().toString().slice(-2)),t=t.replace("MM",(this.getMonth()+1).toString().padStart(2,"0")),t=t.replace("dd",this.getDate().toString().padStart(2,"0")),t=t.replace("HH",this.getHours().toString().padStart(2,"0")),t=t.replace("hh",(this.getHours()>12?this.getHours()-12:this.getHours()).toString().padStart(2,"0")),t=t.replace("mm",this.getMinutes().toString().padStart(2,"0")),t=t.replace("ss",this.getSeconds().toString().padStart(2,"0")),t=t.replace("ff",this.getMilliseconds().toString().padStart(2,"0")),t=t.replace("tt","{5}"),t=t.replace("zz",""),t=t.replace("y",this.getFullYear().toString()),t=t.replace("M",(this.getMonth()+1).toString()),t=t.replace("d",this.getDate().toString()),t=t.replace("H",this.getHours().toString()),t=t.replace("h",(this.getHours()>12?this.getHours()-12:this.getHours()).toString()),t=t.replace("m",this.getMinutes().toString()),t=t.replace("s",this.getSeconds().toString()),t=t.replace("z",""),t=t.replace("t","{6}"),t=t.replace("Z",""),t=t.replace("{1}",this.toLocaleString("default",{month:"long"})),t=t.replace("{2}",this.toLocaleString("default",{weekday:"long"})),t=t.replace("{3}",this.toLocaleString("default",{month:"short"})),t=t.replace("{4}",this.toLocaleString("default",{weekday:"short"})),t=t.replace("{5}",this.getHours()>=12?"PM":"AM"),t=t.replace("{6}",this.getHours()>=12?"P":"A"),t}},874:()=>{Document.ready=async function(e){!async function(){"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",(function(){e()}))}()},Document.getWidth=function(e){return null==e||void 0===e?0:e.offsetWidth||e.innerWidth||e.clientWidth},Document.getHeight=function(e){return null==e||void 0===e?0:e.offsetHeight||e.innerHeight||e.clientHeight},Document.appendHtml=function(e,t){const n=document.createElement(t);e.appendChild(n)},Document.addClass=function(e,t){e.classList.contains(t)||e.classList.add(t)},Document.removeClass=function(e,t){e.classList.contains(t)&&e.classList.remove(t)}},705:()=>{Math.randomN=function(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e)+e)},Math.average=function(e){let t=0;return e.forEach((e=>{t+=parseFloat(e)})),t/e.length},Math.avg=function(...e){let t=0;return e.forEach((e=>{t+=parseFloat(e)})),t/e.length},Math.half=function(e){return e/2}},428:()=>{Object.isNullOrUndefined=function(e){return void 0===e||null==e},Object.getDataType=function(e){return String.isNullOrUndefined(e)?"null":"object"==typeof e?Array.isArray(e)?"array":"object":typeof e}},930:()=>{String.isNullOrUndefined=function(e){return void 0===e||null==e},String.isNullOrWhitespace=function(e){return!!String.isNullOrUndefined(e)||("string"==typeof e?e.trim().length<=0:e.toString().trim().length<=0)},String.joinIfNotNullOrWhitespace=function(e,...t){let n="";for(let r=0;r$1")},String.prototype.toTitleCase=function(){let e=this;return e=e.replace(/([A-Z]{1})/g," $1"),e=e.trim(),e=e.charAt(0).toUpperCase()+e.substr(1),e},String.prototype.getFilename=function(){return this.substring(this.lastIndexOf("/")+1)}},323:()=>{Window.goToTop=function(){Window.scrollTo(0,0)},Window.fragment={get:function(){if(!window.location.hash)return null;const e=window.location.hash.indexOf("?");return e<0?window.location.hash.substring(1):window.location.hash.substring(1,e)},getQuery:function(){if(!window.location.hash)return null;let e=window.location.hash;const t=e.indexOf("?");if(t<0)return null;e=hasQueryString.substring(t+1);const n=new URLSearchParams(e),r={};for(const[e,t]of n.entries())r[e]=t;return r},clear:function(){location.hash="",history.replaceState("","",location.pathname)}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n(814),n(523),n(579),n(874),n(705),n(428),n(930),n(323)})(),r})(),e.exports=t()}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}return(()=>{"use strict";n(645);const e=class{GenerateCheckBox(e,t,n){let r="";return r+='
',r+='",r+='",r+="
",r}GenerateCols(...e){let t="";for(let n=0;n'+e[n]+"";return t}GenerateCSVLine(e,...t){1===t.length&&"array"==Object.getDataType(t[0])&&(t=t[0]);let n="";for(let r=0;r0&&(n+=e),n+=t[r];return n}GenerateRadioBox(e,t,n,r,o){let i="";return i+='
',i+='",i+='",i+="
",i}GenerateRow(...e){const t=this;1===e.length&&"array"==Object.getDataType(e[0])&&(e=e[0]);let n="";for(let r=0;r"+n+""}GenerateRowCell(e){return''}SetHtml(e,t){null!=e&&(e.innerHTML=t)}},t=new class extends e{#e=null;#t=null;constructor(e){super(),this.#t=e}InitialiseComponents(){const e=this;e.Clear(),e.#n(),e.#r(),e.Button1.addEventListener("click",(async function(t){e.Button2.disabled=!0,e.TextBox1.value="",await e.Search(),e.Button2.disabled=!1})),e.Button2.addEventListener("click",(async function(t){e.Button2.disabled=!0,await e.Search(),e.Button2.disabled=!1}))}#n(){const e=this;let t="";t+=e.GenerateCheckBox(1,"Show Anchor as HTML",!1),t+=e.GenerateCheckBox(4,"Resolve Relative URL",!1);let n="";n+=e.GenerateCheckBox(3,"Sort By Anchor Text",!0),n+=e.GenerateCheckBox(2,"Trim Anchor Text",!0);let r=e.GenerateCols(t,n);e.SetHtml(e.Panel1,r)}#r(){const e=this;let t="";t+=e.GenerateCheckBox(12,"Hide External Links",!0),t+=e.GenerateCheckBox(5,"Hide Duplicates",!0),t+=e.GenerateCheckBox(14,"Hide Blank Anchors",!0),t+=e.GenerateCheckBox(15,"Hide Blank Links",!0),t+=e.GenerateCheckBox(11,"Hide Fragments",!0),t+=e.GenerateCheckBox(13,"Hide Mailto/Tel",!0),t+=e.GenerateCheckBox(16,"Hide Javascript",!0);let n="";n+=e.GenerateCheckBox(6,"Show Title",!0),n+=e.GenerateCheckBox(7,"Show Target",!1),n+=e.GenerateCheckBox(8,"Show Rel",!1),n+=e.GenerateCheckBox(9,"Show Type",!1),n+=e.GenerateCheckBox(10,"Show Count",!1);let r=e.GenerateCols(t,n);e.SetHtml(e.Panel2,r)}get Button1(){return null==this.Container?null:this.Container.querySelectorAll("button")[0]}get Button2(){return null==this.Container?null:this.Container.querySelectorAll("button")[1]}get Container(){const e=this;return null==e.#e&&(e.#e=document.getElementById("nav-hyperlinks")),e.#e}get Label1(){return null==this.Container?null:this.Container.querySelectorAll("[role='label']")[0]}get MemoBox1(){return null==this.Container?null:this.Container.querySelectorAll("textarea")[0]}get Panel1(){return null==this.Container?null:this.Container.querySelectorAll("div[role='options']")[0]}get Panel2(){return null==this.Container?null:this.Container.querySelectorAll("div[role='filters']")[0]}get Table1(){return null==this.Container?null:this.Container.querySelectorAll("table")[0]}get TextBox1(){return null==this.Container?null:this.Container.querySelectorAll("input[role='textbox']")[0]}Clear(){const e=this;e.Table1.style.display="none",e.MemoBox1.style.display="none",e.SetHtml(e.Panel1,""),e.SetHtml(e.Panel2,"")}async Search(){const e=this;e.Label1.innerText="",e.Table1.style.display="none",e.MemoBox1.style.display="none";const t=await e.#t.GetHyperlinks(),n=t.length,r=await e.#o(t.copy());switch(r.length==n?e.Label1.innerText="Showing "+n+" result"+(1==n?"":"s"):e.Label1.innerText="Showing "+r.length+" of "+n+" result"+(1==n?"":"s"),e.#i(2)){case"table":e.#l(r);break;case"csv":e.#a(r);break;case"links":e.#s(r)}}async#o(e){const t=this,n=await t.#t.GetLocation(),r=new URL(n).hostname;let o=[];for(let i=0;iJSON.stringify(e)===JSON.stringify(o[t]))).length;e.push(n)}for(let t=0;t"+t[r].name+"");return n}#c(e){if(null==this.Container)return!1;const t=this.Container.querySelectorAll("input[id='checkbox"+e+"']");return!(t.length<=0)&&t[0].checked}#i(e){if(null==this.Container)return"";const t=this.Container.querySelectorAll("select[name='comboBox"+e+"']");return t.length<=0?"":t[0].value}#h(e){if(null==this.Container)return"";const t=this.Container.querySelectorAll("input[name='radioGroup"+e+"']:checked");return t.length<=0?"":t[0].value}#l(e){const t=this,n=t.Table1.querySelectorAll("thead")[0],r=t.Table1.querySelectorAll("tbody")[0];n.innerHTML="",r.innerHTML="",t.Table1.style.display="table",n.innerHTML=""+t.#u()+"";for(let n=0;n(()=>{var e={645:function(e){var t;t=()=>(()=>{var e={814:()=>{Array.isEmpty=function(e){return"array"!=Object.getDataType(e)||e.length<=0},Array.toFlatten=function(e,t,n){for(let r=0;r0&&Array.toFlatten(e[r][t],t,n)},Array.prototype.addRange=function(e){return null==e||e.forEach((e=>{this.push(e)})),this},Array.prototype.all=function(e,t){for(let n=0;n{t+=this.count(e.propName,e.value)})),t},Array.prototype.create=function(e,t){let n=[];for(let r=0;rt===n.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)))))},Array.prototype.flatten=function(e){let t=[];return Array.toFlatten(this,e,t),t},Array.prototype.get=function(e){return e<0||e>=this.length?"":this[e]},Array.prototype.index=function(e,t){const n=this.indexes(e,t);return n.length<=0?null:n[0]},Array.prototype.indexes=function(e,t){let n=[];for(let r=0;r=this.length?this.push(t):this.splice(e,0,t),this},Array.prototype.joinIfNotNullOrWhitespace=function(e){let t="";for(let n=0;nn[e]?1:0})),this},Array.prototype.orderByDesc=function(e){return this.sort((function(t,n){return t[e]n[e]?-1:0})),this},Array.prototype.remove=function(e){let t=[];for(let n=0;n=0;e--)this.removeAt(t[e]);return this},Array.prototype.removeAt=function(e){return e<0||e>=this.length||this.splice(e,1),this},Array.prototype.removeRange=function(e){for(let t=0;t{t=t.select(e.propName,e.value)})),t},Array.prototype.toList=function(e){let t=[];return this.forEach((n=>{null!=typeof n[e]&&t.push(n[e])})),t},Array.prototype.sortTree=function(e,t){this.orderBy(t);for(let n=0;n{Boolean.isFalse=function(e){return!!String.isNullOrUndefined(e)||e.toString().containsCI("false","f","y","0","x")},Boolean.isTrue=function(e){return!String.isNullOrUndefined(e)&&e.toString().containsCI("true","t","n","1","o")},Boolean.ifTrue=function(e,t,n){return Boolean.isTrue(e)?t:n}},579:()=>{Date.addDays=function(e,t){let n=new Date(e);return n.addDays(t),n},Date.addMonths=function(e,t){let n=new Date(e);return n.addMonths(t),n},Date.addYears=function(e,t){let n=new Date(e);return n.addYears(t),n},Date.max=function(e,t){return null==e?t:null==t?e:new Date(e)<=new Date(t)?new Date(t):new Date(e)},Date.min=function(e,t){return null==e?t:null==t?e:new Date(e)<=new Date(t)?new Date(e):new Date(t)},Date.diffDays=function(e,t){return Math.ceil((new Date(t).getTime()-new Date(e).getTime())/864e5)},Date.today=function(){let e=new Date;return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),e},Date.prototype.addDays=function(e){this.setDate(this.getDate()+parseInt(e))},Date.prototype.addMonths=function(e){this.setMonth(this.getMonth()+parseInt(e))},Date.prototype.addYears=function(e){this.setFullYear(this.getFullYear()+parseInt(e))},Date.prototype.toCString=function(e){let t=e;return t=t.replace("fffffff",this.getMilliseconds().toString().padStart(7,"0")),t=t.replace("ffffff",this.getMilliseconds().toString().padStart(6,"0")),t=t.replace("fffff",this.getMilliseconds().toString().padStart(5,"0")),t=t.replace("yyyy",this.getFullYear().toString().padStart(4,"0")),t=t.replace("MMMM","{1}"),t=t.replace("dddd","{2}"),t=t.replace("ffff",this.getMilliseconds().toString().padStart(4,"0")),t=t.replace("yyy",this.getFullYear().toString().padStart(3,"0")),t=t.replace("MMM","{3}"),t=t.replace("ddd","{4}"),t=t.replace("fff",this.getMilliseconds().toString().padStart(3,"0")),t=t.replace("zzz",""),t=t.replace("yy",this.getFullYear().toString().slice(-2)),t=t.replace("MM",(this.getMonth()+1).toString().padStart(2,"0")),t=t.replace("dd",this.getDate().toString().padStart(2,"0")),t=t.replace("HH",this.getHours().toString().padStart(2,"0")),t=t.replace("hh",(this.getHours()>12?this.getHours()-12:this.getHours()).toString().padStart(2,"0")),t=t.replace("mm",this.getMinutes().toString().padStart(2,"0")),t=t.replace("ss",this.getSeconds().toString().padStart(2,"0")),t=t.replace("ff",this.getMilliseconds().toString().padStart(2,"0")),t=t.replace("tt","{5}"),t=t.replace("zz",""),t=t.replace("y",this.getFullYear().toString()),t=t.replace("M",(this.getMonth()+1).toString()),t=t.replace("d",this.getDate().toString()),t=t.replace("H",this.getHours().toString()),t=t.replace("h",(this.getHours()>12?this.getHours()-12:this.getHours()).toString()),t=t.replace("m",this.getMinutes().toString()),t=t.replace("s",this.getSeconds().toString()),t=t.replace("z",""),t=t.replace("t","{6}"),t=t.replace("Z",""),t=t.replace("{1}",this.toLocaleString("default",{month:"long"})),t=t.replace("{2}",this.toLocaleString("default",{weekday:"long"})),t=t.replace("{3}",this.toLocaleString("default",{month:"short"})),t=t.replace("{4}",this.toLocaleString("default",{weekday:"short"})),t=t.replace("{5}",this.getHours()>=12?"PM":"AM"),t=t.replace("{6}",this.getHours()>=12?"P":"A"),t}},874:()=>{Document.ready=async function(e){!async function(){"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",(function(){e()}))}()},Document.getWidth=function(e){return null==e||void 0===e?0:e.offsetWidth||e.innerWidth||e.clientWidth},Document.getHeight=function(e){return null==e||void 0===e?0:e.offsetHeight||e.innerHeight||e.clientHeight},Document.appendHtml=function(e,t){const n=document.createElement(t);e.appendChild(n)},Document.addClass=function(e,t){e.classList.contains(t)||e.classList.add(t)},Document.removeClass=function(e,t){e.classList.contains(t)&&e.classList.remove(t)}},705:()=>{Math.randomN=function(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e)+e)},Math.average=function(e){let t=0;return e.forEach((e=>{t+=parseFloat(e)})),t/e.length},Math.avg=function(...e){let t=0;return e.forEach((e=>{t+=parseFloat(e)})),t/e.length},Math.half=function(e){return e/2}},428:()=>{Object.isNullOrUndefined=function(e){return void 0===e||null==e},Object.getDataType=function(e){return String.isNullOrUndefined(e)?"null":"object"==typeof e?Array.isArray(e)?"array":"object":typeof e}},930:()=>{String.isNullOrUndefined=function(e){return void 0===e||null==e},String.isNullOrWhitespace=function(e){return!!String.isNullOrUndefined(e)||("string"==typeof e?e.trim().length<=0:e.toString().trim().length<=0)},String.joinIfNotNullOrWhitespace=function(e,...t){let n="";for(let r=0;r$1")},String.prototype.toTitleCase=function(){let e=this;return e=e.replace(/([A-Z]{1})/g," $1"),e=e.trim(),e=e.charAt(0).toUpperCase()+e.substr(1),e},String.prototype.getFilename=function(){return this.substring(this.lastIndexOf("/")+1)}},323:()=>{Window.goToTop=function(){Window.scrollTo(0,0)},Window.fragment={get:function(){if(!window.location.hash)return null;const e=window.location.hash.indexOf("?");return e<0?window.location.hash.substring(1):window.location.hash.substring(1,e)},getQuery:function(){if(!window.location.hash)return null;let e=window.location.hash;const t=e.indexOf("?");if(t<0)return null;e=hasQueryString.substring(t+1);const n=new URLSearchParams(e),r={};for(const[e,t]of n.entries())r[e]=t;return r},clear:function(){location.hash="",history.replaceState("","",location.pathname)}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n(814),n(523),n(579),n(874),n(705),n(428),n(930),n(323)})(),r})(),e.exports=t()}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}return(()=>{"use strict";n(645);const e=class{GenerateCheckBox(e,t,n){let r="";return r+='
',r+='",r+='",r+="
",r}GenerateCols(...e){let t="";for(let n=0;n'+e[n]+"";return t}GenerateCSVLine(e,...t){1===t.length&&"array"==Object.getDataType(t[0])&&(t=t[0]);let n="";for(let r=0;r0&&(n+=e),n+=t[r];return n}GenerateRadioBox(e,t,n,r,o){let i="";return i+='
',i+='",i+='",i+="
",i}GenerateRow(...e){const t=this;1===e.length&&"array"==Object.getDataType(e[0])&&(e=e[0]);let n="";for(let r=0;r"+n+""}GenerateRowCell(e){return''}SetHtml(e,t){null!=e&&(e.innerHTML=t)}},t=new class{async SendMessage(e,t){chrome.tabs.query({active:!0,currentWindow:!0},(function(n){chrome.tabs.sendMessage(n[0].id,{event:e},t)}))}async GetHyperlinks(){const e=this;return new Promise((function(t){e.SendMessage("GetHyperlinkNodes",(async function(e){t(e.copy())}))}))}async GetImages(){const e=this;return new Promise((function(t){e.SendMessage("GetImageNodes",(async function(e){t(e.copy())}))}))}async GetLocation(){const e=this;return new Promise((function(t){e.SendMessage("GetLocation",(function(e){t(e)}))}))}},r=new class extends e{#e=null;#t=null;constructor(e){super(),this.#t=e}InitialiseComponents(){const e=this;e.Clear(),e.#n(),e.#r(),e.Button1.addEventListener("click",(async function(t){e.Button2.disabled=!0,e.TextBox1.value="",await e.Search(),e.Button2.disabled=!1})),e.Button2.addEventListener("click",(async function(t){e.Button2.disabled=!0,await e.Search(),e.Button2.disabled=!1}))}#n(){const e=this;let t="";t+=e.GenerateCheckBox(1,"Show Anchor as HTML",!1),t+=e.GenerateCheckBox(4,"Resolve Relative URL",!1);let n="";n+=e.GenerateCheckBox(3,"Sort By Anchor Text",!0),n+=e.GenerateCheckBox(2,"Trim Anchor Text",!0);let r=e.GenerateCols(t,n);e.SetHtml(e.Panel1,r)}#r(){const e=this;let t="";t+=e.GenerateCheckBox(12,"Hide External Links",!0),t+=e.GenerateCheckBox(5,"Hide Duplicates",!0),t+=e.GenerateCheckBox(14,"Hide Blank Anchors",!0),t+=e.GenerateCheckBox(15,"Hide Blank Links",!0),t+=e.GenerateCheckBox(11,"Hide Fragments",!0),t+=e.GenerateCheckBox(13,"Hide Mailto/Tel",!0),t+=e.GenerateCheckBox(16,"Hide Javascript",!0);let n="";n+=e.GenerateCheckBox(6,"Show Title",!0),n+=e.GenerateCheckBox(7,"Show Target",!1),n+=e.GenerateCheckBox(8,"Show Rel",!1),n+=e.GenerateCheckBox(9,"Show Type",!1),n+=e.GenerateCheckBox(10,"Show Count",!1);let r=e.GenerateCols(t,n);e.SetHtml(e.Panel2,r)}get Button1(){return null==this.Container?null:this.Container.querySelectorAll("button")[0]}get Button2(){return null==this.Container?null:this.Container.querySelectorAll("button")[1]}get Container(){const e=this;return null==e.#e&&(e.#e=document.getElementById("nav-hyperlinks")),e.#e}get Label1(){return null==this.Container?null:this.Container.querySelectorAll("[role='label']")[0]}get MemoBox1(){return null==this.Container?null:this.Container.querySelectorAll("textarea")[0]}get Panel1(){return null==this.Container?null:this.Container.querySelectorAll("div[role='options']")[0]}get Panel2(){return null==this.Container?null:this.Container.querySelectorAll("div[role='filters']")[0]}get Table1(){return null==this.Container?null:this.Container.querySelectorAll("table")[0]}get TextBox1(){return null==this.Container?null:this.Container.querySelectorAll("input[role='textbox']")[0]}Clear(){const e=this;e.Table1.style.display="none",e.MemoBox1.style.display="none",e.SetHtml(e.Panel1,""),e.SetHtml(e.Panel2,"")}async Search(){const e=this;e.Label1.innerText="",e.Table1.style.display="none",e.MemoBox1.style.display="none";const t=await e.#t.GetHyperlinks(),n=t.length,r=await e.#o(t.copy());switch(r.length==n?e.Label1.innerText="Showing "+n+" result"+(1==n?"":"s"):e.Label1.innerText="Showing "+r.length+" of "+n+" result"+(1==n?"":"s"),e.#i(2)){case"table":e.#l(r);break;case"csv":e.#a(r);break;case"links":e.#s(r)}}async#o(e){const t=this,n=await t.#t.GetLocation(),r=new URL(n).hostname;let o=[];for(let i=0;iJSON.stringify(e)===JSON.stringify(o[t]))).length;e.push(n)}for(let t=0;t"+t[r].name+"");return n}#c(e){if(null==this.Container)return!1;const t=this.Container.querySelectorAll("input[name='checkbox"+e+"']");return!(t.length<=0)&&t[0].checked}#i(e){if(null==this.Container)return"";const t=this.Container.querySelectorAll("select[name='comboBox"+e+"']");return t.length<=0?"":t[0].value}#h(e){if(null==this.Container)return"";const t=this.Container.querySelectorAll("input[name='radioGroup"+e+"']:checked");return t.length<=0?"":t[0].value}#l(e){const t=this,n=t.Table1.querySelectorAll("thead")[0],r=t.Table1.querySelectorAll("tbody")[0];n.innerHTML="",r.innerHTML="",t.Table1.style.display="table",n.innerHTML=""+t.#u()+"";for(let n=0;nJSON.stringify(e)===JSON.stringify(o[t]))).length;e.push(n)}for(let t=0;t"+t[r].name+"");return n}#c(e){if(null==this.Container)return!1;const t=this.Container.querySelectorAll("input[name='checkbox"+e+"']");return!(t.length<=0)&&t[0].checked}#i(e){if(null==this.Container)return"";const t=this.Container.querySelectorAll("select[name='comboBox"+e+"']");return t.length<=0?"":t[0].value}#l(e){const t=this,n=t.Table1.querySelectorAll("thead")[0],r=t.Table1.querySelectorAll("tbody")[0];n.innerHTML="",r.innerHTML="",t.Table1.style.display="table",n.innerHTML=""+t.#u()+"";for(let n=0;n - + - - - - - - - - - - - - \ No newline at end of file diff --git a/src/src/popup.js b/src/src/popup.js index b445626..a041e71 100644 --- a/src/src/popup.js +++ b/src/src/popup.js @@ -1,14 +1,17 @@ // src/popup.js import PopupService from './popup/popup-service.js'; import AContentService from './popup/acontent-service.js'; +import ImgContentService from './popup/imgcontent-service.js'; const popupService = new PopupService(); -const acontentService = new AContentService(popupService); +const aContentService = new AContentService(popupService); +const imgContentService = new ImgContentService(popupService); document.addEventListener("DOMContentLoaded", async function(event) { - acontentService.InitialiseComponents(); + aContentService.InitialiseComponents(); + imgContentService.InitialiseComponents(); }); \ No newline at end of file diff --git a/src/src/popup/acontent-service.js b/src/src/popup/acontent-service.js index a2d6378..5269fb8 100644 --- a/src/src/popup/acontent-service.js +++ b/src/src/popup/acontent-service.js @@ -234,7 +234,7 @@ class AContentService extends ContentService { } } - // Hide Blank Links + // Hide blank links if (a.#getCheckBox(15)) { if (String.isNullOrWhitespace(item.href)) { continue; @@ -267,7 +267,7 @@ class AContentService extends ContentService { // Show anchor as html let text = (a.#getCheckBox(1) ? item.innerHTML : item.innerText); - // Hide Blank Anchors + // Hide blank anchors if (a.#getCheckBox(14)) { if (String.isNullOrWhitespace(text)) { continue; @@ -365,7 +365,7 @@ class AContentService extends ContentService { return false; } - const result = a.Container.querySelectorAll("input[id='checkbox" + num + "']"); + const result = a.Container.querySelectorAll("input[name='checkbox" + num + "']"); if (result.length <= 0) { return false; } diff --git a/src/src/popup/content-service.js b/src/src/popup/content-service.js index ca5dc67..bf893a2 100644 --- a/src/src/popup/content-service.js +++ b/src/src/popup/content-service.js @@ -5,7 +5,7 @@ class ContentService { GenerateCheckBox(num, label, checked) { let html = ""; html += "
"; - html += ""; + html += ""; html += ""; html += "
"; diff --git a/src/src/popup/imgcontent-service.js b/src/src/popup/imgcontent-service.js new file mode 100644 index 0000000..f27bd3f --- /dev/null +++ b/src/src/popup/imgcontent-service.js @@ -0,0 +1,444 @@ +import '../../../literyz-js/extensions.dist.js'; + +import ContentService from './content-service.js'; + + +class ImgContentService extends ContentService { + #containerPanel = null; + #popupService = null; + + + constructor(popupService) { + super(); + + this.#popupService = popupService; + } + + InitialiseComponents() { + const a = this; + + a.Clear(); + + a.#initialiseComponents_Options(); + a.#initialiseComponents_Filters(); + + a.Button1.addEventListener('click', async function (e) { + a.Button2.disabled = true; + + a.TextBox1.value = ""; + + await a.Search(); + + a.Button2.disabled = false; + }); + + a.Button2.addEventListener('click', async function (e) { + a.Button2.disabled = true; + + await a.Search(); + + a.Button2.disabled = false; + }); + } + + #initialiseComponents_Options() { + const a = this; + + let col1 = ""; + col1 += a.GenerateCheckBox(203, "Sort By Source URL", true); + col1 += a.GenerateCheckBox(204, "Resolve Relative URL", false); + + let col2 = ""; + col2 += a.GenerateCheckBox(202, "Trim Alternate Text", true); + + let html = a.GenerateCols(col1, col2); + + a.SetHtml(a.Panel1, html); + } + + #initialiseComponents_Filters() { + const a = this; + + let col1 = ""; + col1 += a.GenerateCheckBox(212, "Hide External Links", false); + col1 += a.GenerateCheckBox(205, "Hide Duplicates", true); + col1 += a.GenerateCheckBox(214, "Hide Blank Alternate Text", false); + col1 += a.GenerateCheckBox(215, "Hide Blank Source URL", true); + + let col2 = ""; + col2 += a.GenerateCheckBox(206, "Show Alternative Text", true); + col2 += a.GenerateCheckBox(207, "Show Source Set", false); + col2 += a.GenerateCheckBox(208, "Show Image Map", false); + // col2 += a.GenerateCheckBox(209, "Show Width", false); + // col2 += a.GenerateCheckBox(210, "Show Height", false); + col2 += a.GenerateCheckBox(210, "Show Count", false); + + let html = a.GenerateCols(col1, col2); + + a.SetHtml(a.Panel2, html); + } + + + get Button1() { + const a = this; + + if (a.Container == null) { + return null; + } + + return a.Container.querySelectorAll("button")[0]; + } + + get Button2() { + const a = this; + + if (a.Container == null) { + return null; + } + + return a.Container.querySelectorAll("button")[1]; + } + + get Container() { + const a = this; + + if (a.#containerPanel == null) { + a.#containerPanel = document.getElementById("nav-images"); + } + + return a.#containerPanel; + } + + get Label1() { + const a = this; + + if (a.Container == null) { + return null; + } + + return a.Container.querySelectorAll("[role='label']")[0]; + } + + get MemoBox1() { + const a = this; + + if (a.Container == null) { + return null; + } + + return a.Container.querySelectorAll("textarea")[0]; + } + + get Panel1() { + const a = this; + + if (a.Container == null) { + return null; + } + + return a.Container.querySelectorAll("div[role='options']")[0]; + } + + get Panel2() { + const a = this; + + if (a.Container == null) { + return null; + } + + return a.Container.querySelectorAll("div[role='filters']")[0]; + } + + get Table1() { + const a = this; + + if (a.Container == null) { + return null; + } + + return a.Container.querySelectorAll("table")[0]; + } + + get TextBox1() { + const a = this; + + if (a.Container == null) { + return null; + } + + return a.Container.querySelectorAll("input[role='textbox']")[0]; + } + + + Clear() { + const a = this; + + a.Table1.style.display = 'none'; + a.MemoBox1.style.display = 'none'; + + a.SetHtml(a.Panel1, ""); + a.SetHtml(a.Panel2, ""); + } + + async Search() { + const a = this; + + a.Label1.innerText = ""; + + a.Table1.style.display = 'none'; + a.MemoBox1.style.display = 'none'; + + const result = await a.#popupService.GetImages(); + const totalCount = result.length; + + const newResults = await a.#filterResult(result.copy()); + + if (newResults.length == totalCount) { + a.Label1.innerText = "Showing " + totalCount + " result" + (totalCount == 1 ? "" : "s"); + } else { + a.Label1.innerText = "Showing " + newResults.length + " of " + totalCount + " result" + (totalCount == 1 ? "" : "s"); + } + + switch (a.#getComboBox(2)) { + case "table": + a.#renderTable(newResults); + break; + case "csv": + a.#renderCSV(newResults); + break; + case "links": + a.#renderLinks(newResults); + break; + default: + break; + } + } + + async #filterResult(items) { + const a = this; + const currentUrl = await a.#popupService.GetLocation(); + const currentHostname = (new URL(currentUrl)).hostname; + + let result = []; + + for (let i=0; i JSON.stringify(item) === JSON.stringify(result[i])).length; + + occurrenceCache.push(occurrence); + } + + // Update result with occurrence + for (let i=0; i"; + } + } + + return html; + } + + #getCheckBox(num) { + const a = this; + + if (a.Container == null) { + return false; + } + + const result = a.Container.querySelectorAll("input[name='checkbox" + num + "']"); + if (result.length <= 0) { + return false; + } + + return result[0].checked; + } + + #getComboBox(num) { + const a = this; + + if (a.Container == null) { + return ""; + } + + const result = a.Container.querySelectorAll("select[name='comboBox" + num + "']"); + if (result.length <= 0) { + return ""; + } + + return result[0].value; + } + + #renderTable(results) { + const a = this; + const thead = a.Table1.querySelectorAll("thead")[0]; + const tbody = a.Table1.querySelectorAll("tbody")[0]; + + thead.innerHTML = ""; + tbody.innerHTML = ""; + + a.Table1.style.display = 'table'; + + // Write thead + thead.innerHTML = "" + a.#generateTHeader() + ""; + + // Write tbody + for (let i=0; i