From 541345513b4fd5e99beb15666907063c0317dc42 Mon Sep 17 00:00:00 2001 From: Marclass Date: Mon, 25 Feb 2019 03:03:32 -0800 Subject: [PATCH 1/2] Add ButtonRuner browser extension ButtonRunner is a Chrome/Fire Fox extension that causes links and buttons on websites to run away from the cursor. --- .../BrowserExtension/ButtonRunner/README.md | 9 ++ .../ButtonRunner/buttonRunner.js | 110 ++++++++++++++++++ .../ButtonRunner/manifest.json | 23 ++++ 3 files changed, 142 insertions(+) create mode 100644 Unofficial/JavaScript/BrowserExtension/ButtonRunner/README.md create mode 100644 Unofficial/JavaScript/BrowserExtension/ButtonRunner/buttonRunner.js create mode 100644 Unofficial/JavaScript/BrowserExtension/ButtonRunner/manifest.json diff --git a/Unofficial/JavaScript/BrowserExtension/ButtonRunner/README.md b/Unofficial/JavaScript/BrowserExtension/ButtonRunner/README.md new file mode 100644 index 0000000..1e25d16 --- /dev/null +++ b/Unofficial/JavaScript/BrowserExtension/ButtonRunner/README.md @@ -0,0 +1,9 @@ +# ButtonRunner + +This extension will cause all links and button html elements to run away from the cursor for a short time when someone tries to click on them. +After fMaxEscapes (default 6) mouseovers the element will return to its original position. + + +Originally written by marclass for Kitboga to use on his twitch stream to help waste tech support scammer's time. + +## License: MIT \ No newline at end of file diff --git a/Unofficial/JavaScript/BrowserExtension/ButtonRunner/buttonRunner.js b/Unofficial/JavaScript/BrowserExtension/ButtonRunner/buttonRunner.js new file mode 100644 index 0000000..5b94886 --- /dev/null +++ b/Unofficial/JavaScript/BrowserExtension/ButtonRunner/buttonRunner.js @@ -0,0 +1,110 @@ + +/** +This extension will cause all links and button html elements to run away from the cursor for a short time when someone tries to click on them. +After fMaxEscapes mouseovers the element will return to its original position. + +Originally written for Kitboga to use on his twitch stream to help waste tech support scammer's time. + +**/ + + +var fMaxEscapes=6;//max number of times an elem will run away from the cursor before returning to its original position +var fTagNames=["a","button"]//tags that will move on mouseover +var maxDelta=90;// max number of px an element will move in x or y direction on mouseover. This value should not be a significant fraction of the screen resolution or elements may move off screen +var BREnabled=true; + + +function moveElem(elem, newTop, newLeft, nopx=false){ + + + if(elem.classList.contains("runningButton")){ + var newDiv=parent; + }else{ + elem.classList.add("runningButton"); + elem.setAttribute("clickTries", 0); + } + if(nopx){ + return; + } + + elem.style["transition-duration"]=".1s";//0.1 seconds + elem.style["transition-timing-function"]="ease-out";//fast at first, then slows down towards end of transition + elem.style.position="relative"; + + var tries =parseInt(elem.getAttribute("clickTries"), 10); + if(tries< (fMaxEscapes) ){ + + elem.style.top = newTop +"px"; + elem.style.left=newLeft +"px"; + + elem.setAttribute("clickTries", tries+1); + }else{ + //return to original position + elem.style.top = "0px"; + elem.style.left="0px"; + } + +} + + +function getRndInteger(min, max) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive +} + +function runAway(elem){ + if(!BREnabled){ + return; + } + var bodyRect = document.body.getBoundingClientRect(), + elemRect = elem.getBoundingClientRect(), + topOffset = elemRect.top - bodyRect.top; + leftOffset = elemRect.left - bodyRect.left; + //console.log("topOffset: "+topOffset); + //console.log("leftOffset: "+leftOffset); + + elem.classList.add("runningButton"); + + //var newTop=getRndInteger(-maxDelta, maxDelta); + var newTop=getRndInteger(0, maxDelta*2); + newTop=newTop-maxDelta; + //console.log("got new top offset: "+newTop); + + + //var newLeft=getRndInteger(-maxDelta, maxDelta); + var newLeft=getRndInteger(0, maxDelta*2); + newLeft=newLeft-maxDelta; + //console.log("got new left offset: "+newLeft); + + + //keep element from moving off screen + //will cause problems if maxDelta is very large relative to screen size, but should never happen with reasonable maxDelta + var absLeft=leftOffset+newLeft; + var absTop=topOffset+newTop; + if(absLeft<0 || absLeft>bodyRect.right){ + newLeft=-newLeft; + } + if(absTop<0 || absTop>bodyRect.bottom){ + newTop=-newTop; + } + + //console.log("setting new offsets: top: "+newTop+" left: "+newLeft); + moveElem(elem, newTop, newLeft); + +} + +if(BREnabled){ + for(var j=0;j Date: Mon, 25 Feb 2019 12:09:27 -0800 Subject: [PATCH 2/2] refactor --- .../ButtonRunner/buttonRunner.js | 23 ++++++++----------- .../ButtonRunner/manifest.json | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Unofficial/JavaScript/BrowserExtension/ButtonRunner/buttonRunner.js b/Unofficial/JavaScript/BrowserExtension/ButtonRunner/buttonRunner.js index 5b94886..ac21b15 100644 --- a/Unofficial/JavaScript/BrowserExtension/ButtonRunner/buttonRunner.js +++ b/Unofficial/JavaScript/BrowserExtension/ButtonRunner/buttonRunner.js @@ -17,12 +17,11 @@ var BREnabled=true; function moveElem(elem, newTop, newLeft, nopx=false){ - if(elem.classList.contains("runningButton")){ - var newDiv=parent; - }else{ + if(!elem.classList.contains("runningButton")){ elem.classList.add("runningButton"); elem.setAttribute("clickTries", 0); } + if(nopx){ return; } @@ -32,7 +31,7 @@ function moveElem(elem, newTop, newLeft, nopx=false){ elem.style.position="relative"; var tries =parseInt(elem.getAttribute("clickTries"), 10); - if(tries< (fMaxEscapes) ){ + if(tries< fMaxEscapes ){ elem.style.top = newTop +"px"; elem.style.left=newLeft +"px"; @@ -48,9 +47,9 @@ function moveElem(elem, newTop, newLeft, nopx=false){ function getRndInteger(min, max) { - min = Math.ceil(min); - max = Math.floor(max); - return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive } function runAway(elem){ @@ -66,15 +65,13 @@ function runAway(elem){ elem.classList.add("runningButton"); - //var newTop=getRndInteger(-maxDelta, maxDelta); - var newTop=getRndInteger(0, maxDelta*2); - newTop=newTop-maxDelta; + var newTop=getRndInteger(-maxDelta, maxDelta); + //console.log("got new top offset: "+newTop); - //var newLeft=getRndInteger(-maxDelta, maxDelta); - var newLeft=getRndInteger(0, maxDelta*2); - newLeft=newLeft-maxDelta; + var newLeft=getRndInteger(-maxDelta, maxDelta); + //console.log("got new left offset: "+newLeft); diff --git a/Unofficial/JavaScript/BrowserExtension/ButtonRunner/manifest.json b/Unofficial/JavaScript/BrowserExtension/ButtonRunner/manifest.json index 73a8adc..6d7545a 100644 --- a/Unofficial/JavaScript/BrowserExtension/ButtonRunner/manifest.json +++ b/Unofficial/JavaScript/BrowserExtension/ButtonRunner/manifest.json @@ -13,7 +13,7 @@ "content_scripts": [ { - //"matches": ["*://*.mozilla.org/*"], + "matches": ["*://*/*"], "js": ["buttonRunner.js"]