From a7393e6f1b24a9dd94447aeb2eb552e48ef256f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit=20=C3=87olako=C4=9Flu?= Date: Fri, 26 Feb 2021 18:05:11 +0300 Subject: [PATCH] Addeed .surf --- install.sh | 3 + suckless/dot_surf/.gitignore | 6 + suckless/dot_surf/bookmarks | 1 + suckless/dot_surf/script.js | 0 suckless/dot_surf/scripts/default.js | 314 +++++++++++++++++++++++++++ 5 files changed, 324 insertions(+) create mode 100644 suckless/dot_surf/.gitignore create mode 100644 suckless/dot_surf/bookmarks create mode 100644 suckless/dot_surf/script.js create mode 100644 suckless/dot_surf/scripts/default.js diff --git a/install.sh b/install.sh index fe62c3f7..00b3987e 100755 --- a/install.sh +++ b/install.sh @@ -23,6 +23,9 @@ ln -s ~/.dotfiles/scripts ~/.scripts # Suckless ln -s ~/.dotfiles/suckless ~/.config/suckless +ln -s ~/.dotfiles/suckless/dot_surf ~/.surf +~/.dotfiles/suckless/build.sh + # Tmux ln -s ~/.dotfiles/tmux/tmux.conf ~/.tmux.conf diff --git a/suckless/dot_surf/.gitignore b/suckless/dot_surf/.gitignore new file mode 100644 index 00000000..de107e61 --- /dev/null +++ b/suckless/dot_surf/.gitignore @@ -0,0 +1,6 @@ +cache +certificates +cookies.txt +history +history.txt +tabbed-surf.xid diff --git a/suckless/dot_surf/bookmarks b/suckless/dot_surf/bookmarks new file mode 100644 index 00000000..7388ebfc --- /dev/null +++ b/suckless/dot_surf/bookmarks @@ -0,0 +1 @@ +google.com/search?q=googlwe diff --git a/suckless/dot_surf/script.js b/suckless/dot_surf/script.js new file mode 100644 index 00000000..e69de29b diff --git a/suckless/dot_surf/scripts/default.js b/suckless/dot_surf/scripts/default.js new file mode 100644 index 00000000..c43ae0f6 --- /dev/null +++ b/suckless/dot_surf/scripts/default.js @@ -0,0 +1,314 @@ +/* based on chromium plugin code, adapted by Nibble<.gs@gmail.com> */ +var hint_num_str = ''; +var hint_elems = []; +var hint_open_in_new_tab = false; +var hint_enabled = false; +function hintMode(newtab){ + hint_enabled = true; + if (newtab) { + hint_open_in_new_tab = true; + } else { + hint_open_in_new_tab = false; + } + setHints(); + document.removeEventListener('keydown', initKeyBind, false); + document.addEventListener('keydown', hintHandler, false); + hint_num_str = ''; +} +function hintHandler(e){ + e.preventDefault(); //Stop Default Event + var pressedKey = get_key(e); + if (pressedKey == 'Enter') { + if (hint_num_str == '') + hint_num_str = '1'; + judgeHintNum(Number(hint_num_str)); + } else if (/[0-9]/.test(pressedKey) == false) { + removeHints(); + } else { + hint_num_str += pressedKey; + var hint_num = Number(hint_num_str); + if (hint_num * 10 > hint_elems.length + 1) { + judgeHintNum(hint_num); + } else { + var hint_elem = hint_elems[hint_num - 1]; + if (hint_elem != undefined && hint_elem.tagName.toLowerCase() == 'a') { + setHighlight(hint_elem, true); + } + } + } +} +function setHighlight(elem, is_active) { + if (is_active) { + var active_elem = document.body.querySelector('a[highlight=hint_active]'); + if (active_elem != undefined) + active_elem.setAttribute('highlight', 'hint_elem'); + elem.setAttribute('highlight', 'hint_active'); + } else { + elem.setAttribute('highlight', 'hint_elem'); + } +} +function setHintRules() { + if (document.styleSheets.length < 1) { + var style = document.createElement("style"); + style.appendChild(document.createTextNode("")); + document.head.appendChild(style); + } + var ss = document.styleSheets[0]; + ss.insertRule('a[highlight=hint_elem] {background-color: yellow}', 0); + ss.insertRule('a[highlight=hint_active] {background-color: lime}', 0); +} +function deleteHintRules() { + var ss = document.styleSheets[0]; + ss.deleteRule(0); + ss.deleteRule(0); +} +function judgeHintNum(hint_num) { + var hint_elem = hint_elems[hint_num - 1]; + if (hint_elem != undefined) { + execSelect(hint_elem); + } else { + removeHints(); + } +} +function execSelect(elem) { + var tag_name = elem.tagName.toLowerCase(); + var type = elem.type ? elem.type.toLowerCase() : ""; + if (tag_name == 'a' && elem.href != '') { + setHighlight(elem, true); + // TODO: ajax,