From 1b030104632fcfded6d1e967f1323a1b52d413bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=A7=8D=E6=96=87=E5=8C=96?= <285699686@qq.com> Date: Fri, 25 Mar 2022 01:37:34 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=20:sparkles:=20=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 0 -> 6148 bytes content/content-script.js | 8 ++++++++ icon.png | Bin 0 -> 930 bytes jq.js | 2 ++ login.html | 13 +++++++++++++ manifest.json | 16 ++++++++++++++++ popup.html | 20 ++++++++++++++++++++ popup.js | 13 +++++++++++++ 8 files changed, 72 insertions(+) create mode 100644 .DS_Store create mode 100644 content/content-script.js create mode 100644 icon.png create mode 100644 jq.js create mode 100644 login.html create mode 100644 manifest.json create mode 100644 popup.html create mode 100644 popup.js diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a3ac4e89db1a30af996c2cb3341cc767e06fb5c0 GIT binary patch literal 6148 zcmeHKOHRWu5PdEcv;w5EV}q0n5Q!V4rCC%07W4wp4^>f{APW2JISdEm5b(wxRm6cU z0yHDdJlmOPC(ltP2H*zIvooLvphFjIbs4@exh~$YmX7Qaou6Zl0#7)_2Gd5i4g5w0 zWbcl+TczK*&-?d?B_6n&Dekcut;*?SRZf`ASEaQertjYTLv@%N=19pYu&C#|w*%#FXrUagAA>=T0JC zH{vxJFA;-XGgH76Fa`dM0<76$o&A6oO#xHD6xb>t--m=Qm?>5P{ilP$9|4GM4trx; z&Jw~&6f?ytAg|C|pb`Vs=@G*PI>!^u%M`1CfexpK52q_TJ)tzz!dmb3b^)gJRIHj*A64K35$<1) literal 0 HcmV?d00001 diff --git a/content/content-script.js b/content/content-script.js new file mode 100644 index 0000000..c06b9d0 --- /dev/null +++ b/content/content-script.js @@ -0,0 +1,8 @@ +document.addEventListener("DOMContentLoaded",function(){ + console.log("content"); + + let username = document.getElementsByTagName("input") + + console.log(username[0].value="来说的哈哈圣诞狂欢"); + +}) \ No newline at end of file diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..0a02087f66ef9153b44d1729034c065a80b89c72 GIT binary patch literal 930 zcmV;T16}-yP)Px&TuDShR9Hvtm0xHaRTRd5->f7e8t@M-qKI0AKG>i|kp!y2=+1_cBB+HtXkSu9 zp|(ZI?rg+vkj?BiN+?16*FIRGYAQwAXm+MasrnE>Dj0*J#fl<=(t;?6iOn3D#lVs# z&2F|OFS(ERo^!t6{qDKojwD-Le~P1Dm{ zdorg#YK2%9K(b)1ipU|_4T^$Ih_8c;p1G_5?Y`ZffSrP8fp-+~a;aC7Dc`yb4k7Le zGWx0(h^ie(`POFeKJbl*_X)KEy`Qn$(?ddN_>Bc%+oo(P|;8c3?}be(}s9X@9w|J z^=$}f3%v4NRikPEw_q<~>@fJrF@7AK>K?|lr>r9D)1d>0J6^JN(G`4V!VfcwVU`?K z0VMlvJuo4M0j%u82Xc6{l-7~?3Q6C31?k9P{qeMZU5cP8fRt}<7~FUEI_^F7l>T*n z8%C^a`iGXoIn7jxJU(oRKY!p0;6&i*`MLp8MQgW+F~qhYql0llH*XtpI3?&Qc^a56 z;`ZAUh=Vd(OIb}^3}Q(KT;E0vH2-=fecLD4HtWzbme#iyK=}4C@OR+pv1J3e1$z?X zZ4(cK8GTw=sO?p|y74bgV|*BRdisK1DA@fnK9T4uW%S-+5Q{p{ma{7x8<;?RzK}rq zDEe&|V$h7vFsqRTTzJild(K@?Yuq~vK`aW8^35|y&x+=;jDB8h2d-~lVw`Q6A(hK1 zs*HQ6V7DZUNizyzR)v}X%AIa>ni!gmcxAj-zs(g$`nHD%g}utT1>1}H_!kSWQh@fqKO1>VZowJXdekffaY)KlFM?FjX$V!Z literal 0 HcmV?d00001 diff --git a/jq.js b/jq.js new file mode 100644 index 0000000..c4c6022 --- /dev/null +++ b/jq.js @@ -0,0 +1,2 @@ +/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var _t,zt=[],Ut=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=zt.pop()||S.expando+"_"+wt.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Ut.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ut.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ut,"$1"+r):!1!==e.jsonp&&(e.url+=(Tt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,zt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((_t=E.implementation.createHTMLDocument("").body).innerHTML="
",2===_t.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0 + + + + + + Document + + +

login

+ asasdasd + + \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..15dc84c --- /dev/null +++ b/manifest.json @@ -0,0 +1,16 @@ +{ + "manifest_version": 3, + "name": "passwordmanager", + "version": "0.0.3", + "icons": { + "16": "icon.png", + "48": "icon.png", + "128": "icon.png" + }, + "action": + { + "default_icon": "icon.png", + "default_title": "便捷信息管理", + "default_popup": "popup.html" + } +} \ No newline at end of file diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..dc380de --- /dev/null +++ b/popup.html @@ -0,0 +1,20 @@ + + + + + + + Document + + +
+ 用户名: + 密码: + + +
+ + + + + \ No newline at end of file diff --git a/popup.js b/popup.js new file mode 100644 index 0000000..7b249c8 --- /dev/null +++ b/popup.js @@ -0,0 +1,13 @@ +$("#submitBtn").click(function(){ + + let username = $("#username").val() + console.log(username); + + console.log(document.getElementById("username").value) + + // chrome.action.setPopup({popup:'login.html'}) + window.location.href='login.html' + +}) + + -- Gitee From 6e2015e08ffa731a6bf4b9be3205c60ee0a8263d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=A7=8D=E6=96=87=E5=8C=96?= <285699686@qq.com> Date: Fri, 25 Mar 2022 06:57:41 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=20:sparkles:=20=E5=89=AA=E5=88=87?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/content-script.js | 16 ++++++++++++-- manifest.json | 11 ++++++++-- popup/login.html | 13 +++++++++++ popup/popup.html | 21 ++++++++++++++++++ popup/popup.js | 46 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 popup/login.html create mode 100644 popup/popup.html create mode 100644 popup/popup.js diff --git a/content/content-script.js b/content/content-script.js index c06b9d0..1083ae1 100644 --- a/content/content-script.js +++ b/content/content-script.js @@ -1,8 +1,20 @@ +console.log('这是content script!'); document.addEventListener("DOMContentLoaded",function(){ console.log("content"); let username = document.getElementsByTagName("input") - console.log(username[0].value="来说的哈哈圣诞狂欢"); + console.log(username); -}) \ No newline at end of file +}) + +// 接收来自后台的消息 +chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) +{ + console.log('收到来自 ' + (sender.tab ? "content-script(" + sender.tab.url + ")" : "popup或者background") + ' 的消息:', request); + + let username = document.getElementsByTagName("input") + sendResponse('我收到你的消息了:'+username[0].value); + + username[0].value="request" +}); \ No newline at end of file diff --git a/manifest.json b/manifest.json index 15dc84c..98481d4 100644 --- a/manifest.json +++ b/manifest.json @@ -11,6 +11,13 @@ { "default_icon": "icon.png", "default_title": "便捷信息管理", - "default_popup": "popup.html" - } + "default_popup": "popup/popup.html" + }, + "content_scripts":[ + { + "matches": [""], + "js": ["content/content-script.js"], + "run_at": "document_start" + } + ] } \ No newline at end of file diff --git a/popup/login.html b/popup/login.html new file mode 100644 index 0000000..16246b0 --- /dev/null +++ b/popup/login.html @@ -0,0 +1,13 @@ + + + + + + + Document + + +

login

+ asasdasd + + \ No newline at end of file diff --git a/popup/popup.html b/popup/popup.html new file mode 100644 index 0000000..b4745a3 --- /dev/null +++ b/popup/popup.html @@ -0,0 +1,21 @@ + + + + + + + Document + + +
+ 用户名: + 密码: + + + +
+ + + + + \ No newline at end of file diff --git a/popup/popup.js b/popup/popup.js new file mode 100644 index 0000000..13c5e8a --- /dev/null +++ b/popup/popup.js @@ -0,0 +1,46 @@ +$("#submitBtn").click(function(){ + + let username = $("#username").val() + console.log(username); + + console.log(document.getElementById("username").value) + + // chrome.action.setPopup({popup:'login.html'}) + window.location.href='login.html' + +}) + +$("#read_pass_word").click(()=>{ + sendMessageToContentScript("读取账户信息",(res)=>{ + console.log(res); + $("#username").val(res) + }) +}) +$("#copy_btn").click(()=>{ + let username = $("#username").val() + navigator.clipboard.writeText(username).then(function() { + /* clipboard successfully set */ + }, function() { + /* clipboard write failed */ + }); +}) + +// 向content-script主动发送消息 +function sendMessageToContentScript(message, callback) +{ + getCurrentTabId((tabId) => + { + chrome.tabs.sendMessage(tabId, message, function(response) + { + if(callback) callback(response); + }); + }); +} +// 获取当前选项卡ID +function getCurrentTabId(callback) +{ + chrome.tabs.query({active: true, currentWindow: true}, function(tabs) + { + if(callback) callback(tabs.length ? tabs[0].id: null); + }); +} -- Gitee From 815476e2faa3f92f5aa8c4df09c4f8723f8d366e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=A7=8D=E6=96=87=E5=8C=96?= <285699686@qq.com> Date: Fri, 25 Mar 2022 07:01:00 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=20:fire:=20=E7=A7=BB=E5=8A=A8=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 6148 bytes login.html | 13 ------------- popup.html | 20 -------------------- popup.js | 13 ------------- 4 files changed, 46 deletions(-) delete mode 100644 login.html delete mode 100644 popup.html delete mode 100644 popup.js diff --git a/.DS_Store b/.DS_Store index a3ac4e89db1a30af996c2cb3341cc767e06fb5c0..cc1e4353648489ebe7eb534dc87b5aba6e0975f9 100644 GIT binary patch delta 323 zcmZoMXfc=|#>B!ku~2NHo+2a1#(>?7ixZfc7&#{MFx{;i=7gSqCvcn{QR6G7&|d3 zEHkw{UO>b-Kd&S)GcUCWtRXWc6{sX8JTosPzuYOmG%uwXtTz}aQ4f^i;N;+p7m%o~ zHa4`-Q7|$$snt=awlp%(Q7|z!tF7ha5LMQ<4vNpt$<52}0y+)|7#Sfn122?@QQbfW zl9$SYi}G^v^U{H$ARRmmK@6@8jtnjgzCc=!A(dhCZzct%&Fmcf9Kayj9LW5gc{0C< QBL`416UfNT5h81t0ZOJ&MF0Q* delta 67 zcmZoMXfc=|#>B)qu~2NHo+2aL#(>?7jBJy6Snh7V%4)>4vEdEVW_AvK4xp0Ff*jwO VC-aLqaxee^BLf4=<_M8B%m8x(5WN5Z diff --git a/login.html b/login.html deleted file mode 100644 index 16246b0..0000000 --- a/login.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - Document - - -

login

- asasdasd - - \ No newline at end of file diff --git a/popup.html b/popup.html deleted file mode 100644 index dc380de..0000000 --- a/popup.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - Document - - -
- 用户名: - 密码: - - -
- - - - - \ No newline at end of file diff --git a/popup.js b/popup.js deleted file mode 100644 index 7b249c8..0000000 --- a/popup.js +++ /dev/null @@ -1,13 +0,0 @@ -$("#submitBtn").click(function(){ - - let username = $("#username").val() - console.log(username); - - console.log(document.getElementById("username").value) - - // chrome.action.setPopup({popup:'login.html'}) - window.location.href='login.html' - -}) - - -- Gitee From ead1cefd532268f456cabdde5d14a671f647ca9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=A7=8D=E6=96=87=E5=8C=96?= <285699686@qq.com> Date: Tue, 5 Apr 2022 03:56:06 +0800 Subject: [PATCH 04/10] =?UTF-8?q?:sparkles:=20=E8=AF=BB=E5=8F=96=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/content-script.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/content/content-script.js b/content/content-script.js index 1083ae1..5d3bb2b 100644 --- a/content/content-script.js +++ b/content/content-script.js @@ -17,4 +17,31 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) sendResponse('我收到你的消息了:'+username[0].value); username[0].value="request" -}); \ No newline at end of file + + let passKey = getPassWordIndex() + let password =username.item(passKey) + let loginName = username.item(passKey-1) + console.log(password); + console.log(loginName); + +}); + +function getPassWordIndex() { + let index = 0; + let input = document.getElementsByTagName("input") + for (const key in input) { + if (Object.hasOwnProperty.call(input, key)) { + const element = input[key]; + console.log(element); + if(element.type.indexOf("password")!=-1 + && element.disabled===false + && element.readOnly===false + && window.getComputedStyle(element).getPropertyValue("display")!=="none" + ){ + index = key + return index; + } + + } + } +} \ No newline at end of file -- Gitee From 625978daec2aafefa50af8bb7fc750f324fc3482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=A7=8D=E6=96=87=E5=8C=96?= <285699686@qq.com> Date: Tue, 5 Apr 2022 23:31:40 +0800 Subject: [PATCH 05/10] :sparkles: $.ajax --- .DS_Store | Bin 6148 -> 6148 bytes content/content-script.js | 5 +++++ popup/popup.html | 1 + popup/popup.js | 12 ++++++++++++ 4 files changed, 18 insertions(+) diff --git a/.DS_Store b/.DS_Store index cc1e4353648489ebe7eb534dc87b5aba6e0975f9..9232157630cea9eac2fb8bf074f6d36374ee8fd8 100644 GIT binary patch delta 83 zcmZoMXfc=|#>B)qu~2NHo}wr_0|Nsi1A_nqgC0WxLmorAXHI_d#=_-{jO?5JSavdR jY;a=Q%+A5j0o1ZtkmEb^WPTAx4xlEGE|$#^B5Rld`tT9K delta 146 zcmZoMXfc=|#>B!ku~2NHo}wrR0|Nsi1A_nqLn=caLkWW}Loq}0W=59f%+4SwL55_8 ze6R$PG(!X+T^DymX-ptOy&jGX% ZXzF+7$^0UY96$@1fXWy)M~JLp1^}8fAH)Cv diff --git a/content/content-script.js b/content/content-script.js index 5d3bb2b..f47eaad 100644 --- a/content/content-script.js +++ b/content/content-script.js @@ -8,6 +8,11 @@ document.addEventListener("DOMContentLoaded",function(){ }) + +chrome.runtime.sendMessage("读取已保存的密码",response=>{ +console.log(response); +}) + // 接收来自后台的消息 chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { diff --git a/popup/popup.html b/popup/popup.html index b4745a3..5b14132 100644 --- a/popup/popup.html +++ b/popup/popup.html @@ -13,6 +13,7 @@ + diff --git a/popup/popup.js b/popup/popup.js index 13c5e8a..d175123 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -25,6 +25,18 @@ $("#copy_btn").click(()=>{ }); }) +$("#ajax_btn").click(()=>{ + var settings = { + "url": "http://127.0.0.1:4523/mock/819313/password?url=", + "method": "GET", + "timeout": 0 + }; + + $.ajax(settings).done(function (response) { + console.log(response); + }); +}) + // 向content-script主动发送消息 function sendMessageToContentScript(message, callback) { -- Gitee From 6c4f02aa2911ddaeb6a2465c16e525f8227b440d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=A7=8D=E6=96=87=E5=8C=96?= <285699686@qq.com> Date: Wed, 6 Apr 2022 04:28:38 +0800 Subject: [PATCH 06/10] =?UTF-8?q?:sparkles:=20=E9=9D=99=E6=80=81=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 0 bytes popup/popup.html | 93 ++++++ ...\347\232\204\351\241\265\351\235\242.html" | 269 ++++++++++++++++++ 3 files changed, 362 insertions(+) delete mode 100644 .DS_Store create mode 100644 "popup/popup\347\232\204\351\241\265\351\235\242.html" diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 9232157630cea9eac2fb8bf074f6d36374ee8fd8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKO^?$s5FK~BG|{qB4Wb10#6lGwSG{fkl=p${L1_y%l$SEiQGpvQDdCp4g^ z6wrWo`&Tw~E7`j=rVwK%^p-}HQ-N9D0Wn{N`MJW}#@8g_Gnz#6d}8MK5>3)1FFKvC zqPA7vzR_?R&W`gsxRmpt2#Z<>ht0jk;&A^#%R4weTDH8!!-G!CJ373-T)NKfyZ0WQ4d18Z zOny|_kiaiN*{;DW_=L*JiarF>ES1>>qRhBSXV9}teR=|HLn+>kF~#c|i95($-3zzE z+hp*(s|+-)Sp}>D*Iog0QaL-A~5?$K*?YWtH57X;0L1sjH3Vm diff --git a/popup/popup.html b/popup/popup.html index 5b14132..96c947c 100644 --- a/popup/popup.html +++ b/popup/popup.html @@ -5,8 +5,101 @@ Document + +
+
+
+ +
+
+ +
+
+ +
+
+
+
用户名: 密码: diff --git "a/popup/popup\347\232\204\351\241\265\351\235\242.html" "b/popup/popup\347\232\204\351\241\265\351\235\242.html" new file mode 100644 index 0000000..d293887 --- /dev/null +++ "b/popup/popup\347\232\204\351\241\265\351\235\242.html" @@ -0,0 +1,269 @@ + + + + + + + Document + + + +
+
+
+
+ + + +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+ + +
+ + + +
账户信息填充输入框成功!!!
+
+
+ + + +
复制用户名到剪贴板成功!!!
+
+
+ + + +
复制密码到剪贴板成功!!!
+
+
+
+
+ + \ No newline at end of file -- Gitee From 246555f52a552b3d626f4fadc6923c14e930e746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=A7=8D=E6=96=87=E5=8C=96?= <285699686@qq.com> Date: Thu, 7 Apr 2022 04:18:20 +0800 Subject: [PATCH 07/10] :sparkles: background --- background.js | 19 ++++ content/content-script.js | 20 ++-- manifest.json | 9 +- popup/popup.html | 187 +++++++++++++++++++++++++++++++++++--- popup/popup.js | 24 +++++ 5 files changed, 235 insertions(+), 24 deletions(-) create mode 100644 background.js diff --git a/background.js b/background.js new file mode 100644 index 0000000..4f9e361 --- /dev/null +++ b/background.js @@ -0,0 +1,19 @@ + +// 监听来自content-script的消息 +chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) +{ + console.log('收到来自content-script的消息:'); + console.log(request, sender, sendResponse); + sendResponse('我是后台,我已收到你的消息:' + JSON.stringify(request)); + + +}); + +function testback() { + + fetch('http://127.0.0.1:4523/mock/819313/password?url=') + .then(response => response.json()) + .then(data => console.log(data)); +} + + diff --git a/content/content-script.js b/content/content-script.js index f47eaad..b84fcdf 100644 --- a/content/content-script.js +++ b/content/content-script.js @@ -1,17 +1,21 @@ console.log('这是content script!'); + document.addEventListener("DOMContentLoaded",function(){ console.log("content"); - - let username = document.getElementsByTagName("input") - - console.log(username); - + let url = window.location.host + sendMessageToPopup(url,res=>{ + console.log(res); + }) }) +//发生数据到popup +function sendMessageToPopup(message, callback) { + chrome.runtime.sendMessage(message,response=>{ + callback(response); + }) +} + -chrome.runtime.sendMessage("读取已保存的密码",response=>{ -console.log(response); -}) // 接收来自后台的消息 chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) diff --git a/manifest.json b/manifest.json index 98481d4..13fab28 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "passwordmanager", - "version": "0.0.3", + "version": "0.0.5", "icons": { "16": "icon.png", "48": "icon.png", @@ -19,5 +19,12 @@ "js": ["content/content-script.js"], "run_at": "document_start" } + ], + "background": + { + "service_worker": "background.js" + }, + "permissions":[ + "activeTab","scripting" ] } \ No newline at end of file diff --git a/popup/popup.html b/popup/popup.html index 96c947c..f3bc50d 100644 --- a/popup/popup.html +++ b/popup/popup.html @@ -9,7 +9,7 @@ *{word-wrap:break-word} html,body,h1,h2,h3,h4,h5,h6,hr,p,iframe,dl,dt,dd,ul,ol,li,pre,form,button,input,textarea,th,td,fieldset{margin:0;padding:0} ul,ol,dl{list-style-type:none} - body,th,td,button,input,select,textarea{font-family:"Microsoft Yahei","Hiragino Sans GB","Helvetica Neue",Helvetica,tahoma,arial,Verdana,sans-serif,"WenQuanYi Micro Hei","\5B8B\4F53";font-size:12px;color: #333;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing:grayscale} + body,th,td,button,input,select,textarea{font-family:sans-serif,"Microsoft Yahei","Hiragino Sans GB","Helvetica Neue",Helvetica,tahoma,arial,Verdana,"WenQuanYi Micro Hei","\5B8B\4F53";font-size:12px;color: #333;-moz-osx-font-smoothing:grayscale} .col-lg-12{width:100%} .col-lg-11{width:91.66666666666666%} .col-lg-10{width:83.33333333333334%} @@ -24,7 +24,8 @@ .col-lg-1{width:8.333333333333332%} #container{ - width: 400px; + width: 460px; + padding: 20px 0 20px 0; } #container .row{ display: flex; @@ -83,11 +84,131 @@ border-right-width: 1px; outline: 0; } + .form-item{ + box-sizing: border-box; + margin: 0 0 24px; + padding: 0; + color: #000000d9; + font-size: 14px; + font-variant: tabular-nums; + line-height: 1.5715; + list-style: none; + font-feature-settings: "tnum"; + vertical-align: top; + transition: margin-bottom .3s 17ms linear; + } + .btn { + line-height: 1.5715; + position: relative; + display: inline-block; + font-weight: 400; + white-space: nowrap; + text-align: center; + background-image: none; + border: 1px solid transparent; + box-shadow: 0 2px #00000004; + cursor: pointer; + transition: all .3s cubic-bezier(.645,.045,.355,1); + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + touch-action: manipulation; + height: 32px; + padding: 4px 15px; + font-size: 14px; + border-radius: 2px; + color: #000000d9; + border-color: #d9d9d9; + background: #fff; + } + .btn-sm { + height: 24px; + padding: 0 7px; + font-size: 14px; + border-radius: 2px; + } + .btn-primary { + color: #fff; + border-color: #1890ff; + background: #1890ff; + text-shadow: 0 -1px 0 rgba(0,0,0,.12); + box-shadow: 0 2px #0000000b; + } + .btn-success{ + color: #fff; + border-color: #52c41a; + background: #52c41a; + text-shadow: 0 -1px 0 rgba(0,0,0,.12); + box-shadow: 0 2px #0000000b; + } + .btn-magenta{ + color: #fff; + border-color: #eb2f96; + background: #eb2f96; + text-shadow: 0 -1px 0 rgba(0,0,0,.12); + box-shadow: 0 2px #0000000b; + } + .controller-btn{ + justify-content: center; + } + .btn-box{ + display: flex; + justify-content: space-between; + } + .alert { + box-sizing: border-box; + margin: 0; + color: #000000d9; + font-size: 14px; + font-variant: tabular-nums; + line-height: 1.5715; + list-style: none; + font-feature-settings: "tnum"; + position: relative; + display: flex; + align-items: center; + word-wrap: break-word; + } + .alert-error { + color: #eb2f96; + } + .alert-sccuess{ + color: #52c41a; + } + .alert-info{ + color: #1890ff; + } + .anticon { + display: inline-block; + color: inherit; + font-style: normal; + line-height: 0; + text-align: center; + text-transform: none; + vertical-align: -.125em; + text-rendering: optimizelegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + } + .alert-content{ + margin-left: 2px; + }
-
+
+
+
+ + + +
+
+ +
+
@@ -95,21 +216,57 @@
- +
+
+
+ +
+
+ +
+
+ +
+
+
+
+ + +
+ + + +
账户信息填充输入框成功!!!
+
+
+ + + +
复制用户名到剪贴板成功!!!
+
+
+ + + +
复制密码到剪贴板成功!!!
+
+
+
-
- 用户名: - 密码: - - - - -
- - - + + \ No newline at end of file diff --git a/popup/popup.js b/popup/popup.js index d175123..98473c9 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -1,3 +1,20 @@ +var url = "" + +$("#read_accout").click(()=>{ + +}) + +function ajax() { + var settings = { + "url": "http://127.0.0.1:4523/mock/819313/password?url=", + "method": "GET", + "timeout": 0 + }; + + $.ajax(settings).done(function (response) { + console.log(response); + }); +} $("#submitBtn").click(function(){ let username = $("#username").val() @@ -36,6 +53,13 @@ $("#ajax_btn").click(()=>{ console.log(response); }); }) +// 监听来自content-script的消息 +chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) +{ + console.log('收到来自content-script的消息:'); + console.log(request, sender, sendResponse); + sendResponse('我是后台,我已收到你的消息:' + JSON.stringify(request)); +}); // 向content-script主动发送消息 function sendMessageToContentScript(message, callback) -- Gitee From eb0d9565c3a1bd87847bb88745305692b4df6d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=A7=8D=E6=96=87=E5=8C=96?= <285699686@qq.com> Date: Fri, 8 Apr 2022 07:08:08 +0800 Subject: [PATCH 08/10] :sparkles: content.js-fetch --- background.js | 79 ++++++++++++++++++++++++++----- content/content-script.js | 99 ++++++++++++++++++++++++++++++--------- manifest.json | 2 +- popup/popup.js | 10 +++- 4 files changed, 151 insertions(+), 39 deletions(-) diff --git a/background.js b/background.js index 4f9e361..657a44c 100644 --- a/background.js +++ b/background.js @@ -1,19 +1,72 @@ - // 监听来自content-script的消息 -chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) -{ - console.log('收到来自content-script的消息:'); - console.log(request, sender, sendResponse); - sendResponse('我是后台,我已收到你的消息:' + JSON.stringify(request)); - - +chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { + console.log('收到来自content-script的消息:'); + console.log(request, sender); + sendResponse(request); + if("Accout" == request.type){ + requests("/password","GET",{url:request.host}).then(accout=>{ + if(0 == accout.code){ + console.log(accout); + //sendResponse(request); + getCurrentTabId((id)=>{ + console.log(id); + chrome.action.setBadgeText({text:"A",tabId:id}) + }) + } + }) + } }); -function testback() { - - fetch('http://127.0.0.1:4523/mock/819313/password?url=') - .then(response => response.json()) - .then(data => console.log(data)); +// 获取当前选项卡ID +function getCurrentTabId(callback) +{ + chrome.tabs.query({active: true, currentWindow: true}, function(tabs) + { + if(callback) callback(tabs.length ? tabs[0].id: null); + }); } +// 请求前缀url +const baseUrl = "http://127.0.0.1:4523/mock/819313"; + +/* +* path: 请求路径 +* method: 请求方法 默认get +* data: 请求参数 默认为空 +* */ +function requests(path, method = "GET", data = {}) { + + method = method.toUpperCase(); + + // 默认请求头 + let requestHeader = { + headers: { + 'content-type': 'application/json' + }, + method + }; + + // 如果是get请求 + if (method === "GET") { + // 转换拼接get参数 + let esc = encodeURIComponent; + let queryParams = Object.keys(data) + .map(k => `${esc(k)}=${esc(data[k])}`) + .join('&'); + if(queryParams) path += `?${queryParams}`; + + } else { + // 其他请求 放入body里面 + requestHeader.body = JSON.stringify(data) + } + + // 可以在这封装一个回调函数,请求拦截 + + + // 发送请求并返回 promise 对象 注意 fetch不会拦截其他异常请求️ + return fetch(`${baseUrl}${path}`, requestHeader).then( + // 可在这里封装 响应拦截函数 + response => response.json() + ) +} diff --git a/content/content-script.js b/content/content-script.js index b84fcdf..71cf94a 100644 --- a/content/content-script.js +++ b/content/content-script.js @@ -1,42 +1,50 @@ -console.log('这是content script!'); - +//文档加载完后执行检测 document.addEventListener("DOMContentLoaded",function(){ - console.log("content"); - let url = window.location.host - sendMessageToPopup(url,res=>{ - console.log(res); - }) + //发现有账户信息表单则向后端查询信息 + let passwordIndex = getPassWordIndex() + if(passwordIndex!=undefined){ + let host = window.location.host + sendMessageHandle({"type":"Accout","host":host},res=>{ + console.log(res); + }) + requests("/password","GET",{url:host}).then(accout=>{ + if(0 == accout.code){ + console.log(accout); + + } + }) + } + }) -//发生数据到popup -function sendMessageToPopup(message, callback) { +//发生数据到popup或者background +function sendMessageHandle(message, callback) { chrome.runtime.sendMessage(message,response=>{ callback(response); }) } - - - // 接收来自后台的消息 chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { - console.log('收到来自 ' + (sender.tab ? "content-script(" + sender.tab.url + ")" : "popup或者background") + ' 的消息:', request); - + console.log(request); + console.log(sender); let username = document.getElementsByTagName("input") sendResponse('我收到你的消息了:'+username[0].value); - username[0].value="request" - - let passKey = getPassWordIndex() - let password =username.item(passKey) - let loginName = username.item(passKey-1) - console.log(password); - console.log(loginName); - }); +function setPassword(params) { + console.log(params); +} +/* +let passKey = getPassWordIndex() +let password =username.item(passKey) +let loginName = username.item(passKey-1) +console.log(password); +console.log(loginName); +*/ function getPassWordIndex() { - let index = 0; + let index = undefined; let input = document.getElementsByTagName("input") for (const key in input) { if (Object.hasOwnProperty.call(input, key)) { @@ -53,4 +61,49 @@ function getPassWordIndex() { } } +} + + +// 请求前缀url +const baseUrl = "http://127.0.0.1:4523/mock/819313"; + +/* +* path: 请求路径 +* method: 请求方法 默认get +* data: 请求参数 默认为空 +* */ +function requests(path, method = "GET", data = {}) { + + method = method.toUpperCase(); + + // 默认请求头 + let requestHeader = { + headers: { + 'content-type': 'application/json' + }, + method + }; + + // 如果是get请求 + if (method === "GET") { + // 转换拼接get参数 + let esc = encodeURIComponent; + let queryParams = Object.keys(data) + .map(k => `${esc(k)}=${esc(data[k])}`) + .join('&'); + if(queryParams) path += `?${queryParams}`; + + } else { + // 其他请求 放入body里面 + requestHeader.body = JSON.stringify(data) + } + + // 可以在这封装一个回调函数,请求拦截 + + + // 发送请求并返回 promise 对象 注意 fetch不会拦截其他异常请求️ + return fetch(`${baseUrl}${path}`, requestHeader).then( + // 可在这里封装 响应拦截函数 + response => response.json() + ) } \ No newline at end of file diff --git a/manifest.json b/manifest.json index 13fab28..fe927b7 100644 --- a/manifest.json +++ b/manifest.json @@ -25,6 +25,6 @@ "service_worker": "background.js" }, "permissions":[ - "activeTab","scripting" + "storage","activeTab","scripting" ] } \ No newline at end of file diff --git a/popup/popup.js b/popup/popup.js index 98473c9..746614d 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -1,9 +1,15 @@ var url = "" $("#read_accout").click(()=>{ - + sendMessageToContentScript("读取账户信息",(res)=>{ + console.log(res); + $("#username").val(res) + }) }) - +chrome.scripting.executeScript({ + target:{tabId:111}, + files:["content/content-script.js"] + }) function ajax() { var settings = { "url": "http://127.0.0.1:4523/mock/819313/password?url=", -- Gitee From 7956c3290568f07db74dba546987b6fd3da9101f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=A7=8D=E6=96=87=E5=8C=96?= <285699686@qq.com> Date: Sat, 9 Apr 2022 08:35:29 +0800 Subject: [PATCH 09/10] =?UTF-8?q?:sparkles:=20=E4=BA=A4=E4=BA=92=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 48 ++++----- content/content-script.js | 99 ++++++++++------- manifest.json | 34 +++--- popup/popup.html | 16 +-- popup/popup.js | 220 ++++++++++++++++++++++++++------------ 5 files changed, 257 insertions(+), 160 deletions(-) diff --git a/background.js b/background.js index 657a44c..a0be71c 100644 --- a/background.js +++ b/background.js @@ -1,39 +1,36 @@ // 监听来自content-script的消息 chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { - console.log('收到来自content-script的消息:'); - console.log(request, sender); - sendResponse(request); - if("Accout" == request.type){ - requests("/password","GET",{url:request.host}).then(accout=>{ - if(0 == accout.code){ - console.log(accout); - //sendResponse(request); - getCurrentTabId((id)=>{ - console.log(id); - chrome.action.setBadgeText({text:"A",tabId:id}) + console.log(request, sender); + sendResponse(request); + if ("ACCOUT" == request.type) { + getCurrentTabId((id) => { + console.log(id); + chrome.action.setBadgeText({ + text: "A", + tabId: id + }) }) - } - }) - } + } }); // 获取当前选项卡ID -function getCurrentTabId(callback) -{ - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) - { - if(callback) callback(tabs.length ? tabs[0].id: null); - }); +function getCurrentTabId(callback) { + chrome.tabs.query({ + active: true, + currentWindow: true + }, function (tabs) { + if (callback) callback(tabs.length ? tabs[0].id : null); + }); } // 请求前缀url const baseUrl = "http://127.0.0.1:4523/mock/819313"; /* -* path: 请求路径 -* method: 请求方法 默认get -* data: 请求参数 默认为空 -* */ + * path: 请求路径 + * method: 请求方法 默认get + * data: 请求参数 默认为空 + * */ function requests(path, method = "GET", data = {}) { method = method.toUpperCase(); @@ -53,8 +50,7 @@ function requests(path, method = "GET", data = {}) { let queryParams = Object.keys(data) .map(k => `${esc(k)}=${esc(data[k])}`) .join('&'); - if(queryParams) path += `?${queryParams}`; - + if (queryParams) path += `?${queryParams}`; } else { // 其他请求 放入body里面 requestHeader.body = JSON.stringify(data) diff --git a/content/content-script.js b/content/content-script.js index 71cf94a..290b5b3 100644 --- a/content/content-script.js +++ b/content/content-script.js @@ -1,64 +1,82 @@ +let host = undefined //文档加载完后执行检测 -document.addEventListener("DOMContentLoaded",function(){ +document.addEventListener("DOMContentLoaded", function () { //发现有账户信息表单则向后端查询信息 let passwordIndex = getPassWordIndex() - if(passwordIndex!=undefined){ - let host = window.location.host - sendMessageHandle({"type":"Accout","host":host},res=>{ + if (passwordIndex != undefined) { + host = window.location.host + sendMessageHandle({ + "type": "ACCOUT", + "host": host + }, res => { console.log(res); }) - requests("/password","GET",{url:host}).then(accout=>{ - if(0 == accout.code){ - console.log(accout); - + requests("/accout/list", "POST", { + "host": host + }).then(accout => { + if (0 == accout.code) { + //console.log(accout); + setAccout(accout.data,0) } - }) + }).catch(error => { + console.log(error); + }) } - + }) //发生数据到popup或者background function sendMessageHandle(message, callback) { - chrome.runtime.sendMessage(message,response=>{ + chrome.runtime.sendMessage(message, response => { callback(response); }) } // 接收来自后台的消息 -chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) -{ - console.log(request); - console.log(sender); - let username = document.getElementsByTagName("input") - sendResponse('我收到你的消息了:'+username[0].value); +chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { + if("HOST"==request.type){ + sendResponse({"host":host}) + }else if("SETACCOUT"==request.type){ + + if(undefined==setAccout(request.data,0)){ + sendResponse({"type":"ERROR"}) + }else{ + sendResponse({"type":"SETACCOUT"}) + } + + } }); -function setPassword(params) { - console.log(params); + +function setAccout(data,num) { + let input = document.getElementsByTagName("input") + let passKey = getPassWordIndex() + if(passKey==undefined){ + return undefined; + }else{ + let password =input.item(passKey) + let loginName = input.item(passKey-1) + loginName.value=data[num].username + password.value=data[num].password + } + } -/* -let passKey = getPassWordIndex() -let password =username.item(passKey) -let loginName = username.item(passKey-1) -console.log(password); -console.log(loginName); -*/ function getPassWordIndex() { let index = undefined; let input = document.getElementsByTagName("input") for (const key in input) { if (Object.hasOwnProperty.call(input, key)) { const element = input[key]; - console.log(element); - if(element.type.indexOf("password")!=-1 - && element.disabled===false - && element.readOnly===false - && window.getComputedStyle(element).getPropertyValue("display")!=="none" - ){ + //console.log(element); + if (element.type.indexOf("password") != -1 && + element.disabled === false && + element.readOnly === false && + window.getComputedStyle(element).getPropertyValue("display") !== "none" + ) { index = key return index; } - + } } } @@ -68,10 +86,10 @@ function getPassWordIndex() { const baseUrl = "http://127.0.0.1:4523/mock/819313"; /* -* path: 请求路径 -* method: 请求方法 默认get -* data: 请求参数 默认为空 -* */ + * path: 请求路径 + * method: 请求方法 默认get + * data: 请求参数 默认为空 + * */ function requests(path, method = "GET", data = {}) { method = method.toUpperCase(); @@ -91,7 +109,7 @@ function requests(path, method = "GET", data = {}) { let queryParams = Object.keys(data) .map(k => `${esc(k)}=${esc(data[k])}`) .join('&'); - if(queryParams) path += `?${queryParams}`; + if (queryParams) path += `?${queryParams}`; } else { // 其他请求 放入body里面 @@ -106,4 +124,9 @@ function requests(path, method = "GET", data = {}) { // 可在这里封装 响应拦截函数 response => response.json() ) +} + +window.onerror=(m,u,l,c,e)=>{ + console.log(m,u,l,c,e); + e.message } \ No newline at end of file diff --git a/manifest.json b/manifest.json index fe927b7..f4e03fe 100644 --- a/manifest.json +++ b/manifest.json @@ -7,24 +7,20 @@ "48": "icon.png", "128": "icon.png" }, - "action": - { - "default_icon": "icon.png", - "default_title": "便捷信息管理", - "default_popup": "popup/popup.html" - }, - "content_scripts":[ - { - "matches": [""], - "js": ["content/content-script.js"], - "run_at": "document_start" - } - ], - "background": - { - "service_worker": "background.js" - }, - "permissions":[ - "storage","activeTab","scripting" + "action": { + "default_icon": "icon.png", + "default_title": "便捷信息管理", + "default_popup": "popup/popup.html" + }, + "content_scripts": [{ + "matches": [""], + "js": ["content/content-script.js"], + "run_at": "document_start" + }], + "background": { + "service_worker": "background.js" + }, + "permissions": [ + "storage", "activeTab", "scripting" ] } \ No newline at end of file diff --git a/popup/popup.html b/popup/popup.html index f3bc50d..6806a91 100644 --- a/popup/popup.html +++ b/popup/popup.html @@ -216,18 +216,18 @@
- +
- +
- +
- +
@@ -242,21 +242,21 @@ -
账户信息填充输入框成功!!!
+
账户信息填充输入框成功!!!
-
+ -
+ -
+