-
Notifications
You must be signed in to change notification settings - Fork 18
Add ButtonRuner browser extension #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Marclass
wants to merge
2
commits into
KitbogaCodeville:master
Choose a base branch
from
Marclass:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
Unofficial/JavaScript/BrowserExtension/ButtonRunner/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
107 changes: 107 additions & 0 deletions
107
Unofficial/JavaScript/BrowserExtension/ButtonRunner/buttonRunner.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
|
|
||
| /** | ||
| 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")){ | ||
| 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); | ||
|
|
||
| //console.log("got new top offset: "+newTop); | ||
|
|
||
|
|
||
| var newLeft=getRndInteger(-maxDelta, 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<fTagNames.length;j++){ | ||
| var links=document.getElementsByTagName(fTagNames[j]); | ||
| for(var i=0;i<links.length;i++){ | ||
| links[i].onmouseover=function(){runAway(this)}; | ||
|
|
||
| moveElem(links[i],0,0, true);//hacky solution to elem not doing transition of first mouse over | ||
| } | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
23 changes: 23 additions & 0 deletions
23
Unofficial/JavaScript/BrowserExtension/ButtonRunner/manifest.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
|
|
||
| "manifest_version": 2, | ||
| "name": "Button Runner", | ||
| "version": "1.0", | ||
| "author":"marclass", | ||
|
|
||
| "description": "Makes html buttons and links run away from the cursor.", | ||
|
|
||
| "icons": { | ||
|
|
||
| }, | ||
|
|
||
| "content_scripts": [ | ||
| { | ||
|
|
||
| "matches": ["*://*/*"], | ||
| "js": ["buttonRunner.js"] | ||
|
|
||
| } | ||
| ] | ||
|
|
||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.