ramajs

web browser automation from your browser console
git clone https://tongong.net/git/ramajs.git
Log | Files | Refs | README | LICENSE

commit 3aa0f56a6e3f73babfc1c4566facdc001cfc6a73
parent 12164bd41ac73b639e27b0f550fa61d9cac46e94
Author: tongong <tongong@gmx.net>
Date:   Tue,  1 Dec 2020 17:57:03 +0100

added minified version

Diffstat:
MREADME.md | 17++++++++++++++++-
Arama.min.js | 2++
2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md @@ -26,7 +26,9 @@ in_ = _to frame_. ## installation -**currently missing** +There obviously is no npm-package for this as this would not benefit anyone. To +use rama.js just paste `rama.js` or the minified version `rama.min.js` in your +console or add them to the top of your script. ## documentation @@ -189,6 +191,17 @@ rama.clearcss(); See examples folder +## contributing + +Issues and Pull-Requests are welcome. + +The code is formatted with [prettier][]: the configuration can be found in +`.prettierrc`. To generate `rama.min.js` [terser][] is used: + +```bash +terser -c -m -o rama.min.js -- rama.js +``` + ## other projects I think, at the moment this is the only project with this main idea. But one can @@ -199,3 +212,5 @@ curious about other ideas. [iframe]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe [same-origin policy]: https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy [rama-god]: https://en.wikipedia.org/wiki/Rama +[prettier]: https://github.com/prettier/prettier +[terser]: https://github.com/terser/terser diff --git a/rama.min.js b/rama.min.js @@ -0,0 +1 @@ +rama={number:0,stdparent:document.querySelector("body"),new:function(e){const t={url:window.location.href,parent:this.stdparent,name:"rama-"+this.number};this.number++,"object"!=typeof e&&(e={}),e.hasOwnProperty("url")||(e.url=t.url),e.hasOwnProperty("parent")||(e.parent=t.parent),e.hasOwnProperty("name")||(e.name=t.name),e.hasOwnProperty("id")&&(e.name=e.id),console.log(e);let n=document.createElement("iframe");n.name=e.name,n.src=e.url,n.id=e.name,n.classList.add("rama-frame"),e.parent.appendChild(n);const r={tag:n,t:n,w:n.contentWindow,window:n.contentWindow,name:e.name,id:e.name,waitForReload:function(){return new Promise((e=>{n.addEventListener("load",e,{once:!0})}))},waitFor:function(e,t){return new Promise((n=>{t||(t=500);let o=window.setInterval((()=>{e(r)&&(window.clearInterval(o),n())}),t)}))},waitForSelector:function(e,t){return this.waitFor((t=>t.d&&!!t.d.querySelector(e)),t)},close:function(){this.tag.parentElement.removeChild(this.tag)}};return n.addEventListener("load",(()=>{r.document=n.contentDocument,r.document.qsa=function(e){return Array.from(r.document.querySelectorAll(e))},r.d=r.document})),r},clearpage:function(){this.stdparent=document.querySelector("html"),this.loadcss(".rama-frame { width: 100vw; height: 100vh; position: fixed; top: 0; left: 0; } body { display: none; } html { overflow: hidden; } ")},loadjs:function(e){return new Promise(((t,n)=>{let r=document.createElement("script");r.src=e,r.addEventListener("load",t),r.addEventListener("error",(e=>n(e.error))),document.head.appendChild(r)}))},loadcss:function(e){let t=document.createElement("style");t.innerHTML=e,document.head.appendChild(t)},clearcss:function(){Array.from(document.querySelectorAll("style, link[rel='stylesheet']")).forEach((e=>e.parentElement.removeChild(e)))}}; +\ No newline at end of file