Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions browser_extension/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ def create_fake_cursor():
cursor.id = "fake-cursor"
style = cursor.style
style.position = "fixed"
style.width = "50px"
style.height = "50px"
style.width = "25px"
style.height = "25px"
style.pointerEvents = "none"
style.zIndex = 999999
style.left = "0px"
style.top = "0px"
style.backgroundSize = "cover"
style.backgroundImage = "url('http://127.0.0.1:8000/static/img.png')"
style.backgroundImage = "url('http://127.0.0.1:8000/static/cursors/default.png')"
document.body.appendChild(cursor)
document.body.style.cursor = "none"
return cursor
Expand Down Expand Up @@ -108,6 +108,44 @@ def trigger_click(el):
el.dispatchEvent(event)


def update_cursor(el, cursor):
cursor_style = window.getComputedStyle(el).cursor
final_path = "default"

if cursor_style in ["ne-resize", "nesw-resize", "sw-resize"]:
final_path = "ne-resize"
elif cursor_style in ["nw-resize", "nwse-resize", "se-resize"]:
final_path = "nw-resize"
elif cursor_style in ["n-resize", "ns-resize", "s-resize"]:
final_path = "n-resize"
elif cursor_style in ["w-resize", "ew-resize", "e-resize"]:
final_path = "w-resize"
elif cursor_style in ["all-scroll", "move"]:
final_path = "move"
elif cursor_style in ["not-allowed", "no-drop"]:
final_path = "not-allowed"
elif cursor_style in [
"alias",
"cell",
"col-resize",
"row-resize",
"copy",
"crosshair",
"grab",
"grabbing",
"help",
"pointer",
"progress",
"text",
"vertical-text",
"wait",
"zoom-in",
"zoom-out",
]:
final_path = cursor_style
cursor.style.backgroundImage = f"url('http://127.0.0.1:8000/static/cursors/{final_path}.png')"


def move_and_maybe_click(cursor, offset_x, offset_y, should_click):
current_x = float(cursor.style.left.replace("px", "") or 0)
current_y = float(cursor.style.top.replace("px", "") or 0)
Expand All @@ -126,6 +164,7 @@ def move_and_maybe_click(cursor, offset_x, offset_y, should_click):
console.log(new_x, new_y)

el = document.elementFromPoint(new_x, new_y)
update_cursor(el, cursor)
if should_click and el:
tag = el.tagName.lower()
clickable = (
Expand Down
Binary file added mobile_page/cursors/alias.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/cell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/col-resize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/crosshair.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/grab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/grabbing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/move.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/n-resize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/ne-resize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/not-allowed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/nw-resize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/pointer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/progress.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/row-resize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/vertical-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/w-resize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/wait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/zoom-in.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile_page/cursors/zoom-out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.