From e00fe54b50704d54720891fe99ec4cefdc6ebc2d Mon Sep 17 00:00:00 2001 From: "U-DESKTOP-62AQTPQ\\Paul" Date: Mon, 13 Sep 2021 22:27:19 -0700 Subject: [PATCH 1/4] Removes two actions which no longer worked * next note * previous note --- content_scripts/background.js | 12 ------------ injectable_actions/nextNote.js | 8 -------- injectable_actions/previousNote.js | 7 ------- manifest.json | 8 +------- popup/index.css | 2 +- popup/index.html | 2 +- 6 files changed, 3 insertions(+), 36 deletions(-) delete mode 100644 injectable_actions/nextNote.js delete mode 100644 injectable_actions/previousNote.js diff --git a/content_scripts/background.js b/content_scripts/background.js index 245c05b..ca36b18 100644 --- a/content_scripts/background.js +++ b/content_scripts/background.js @@ -53,18 +53,6 @@ chrome.commands.onCommand.addListener(function (command) { tabs[0].id, {file: "injectable_actions/copyInternalAppLink.js"}); }); - } else if (command === "nextNote") { - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.executeScript( - tabs[0].id, - {file: "injectable_actions/nextNote.js"}); - }); - } else if (command === "previousNote") { - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.executeScript( - tabs[0].id, - {file: "injectable_actions/previousNote.js"}); - }); } else if (command === "newNote") { chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { chrome.tabs.executeScript( diff --git a/injectable_actions/nextNote.js b/injectable_actions/nextNote.js deleted file mode 100644 index c4126ca..0000000 --- a/injectable_actions/nextNote.js +++ /dev/null @@ -1,8 +0,0 @@ -// Get focused element hack (works as of 9/4/2020) -// The element in focus has the following css selector qC87s8opH1X3hjuzPoKrl -var ele = document.querySelector(".qC87s8opH1X3hjuzPoKrl"); -// Hack to find the next note. This will break soon. Already broke once... -var next_ele = ele.parentElement.nextSibling.firstChild; -var id = next_ele.id.split("_")[0]; -// We got the new note id lets navigate to it -window.location.href = `https://www.evernote.com/client/web?login=true#?fs=false&n=${ id }`; diff --git a/injectable_actions/previousNote.js b/injectable_actions/previousNote.js deleted file mode 100644 index e08d3ce..0000000 --- a/injectable_actions/previousNote.js +++ /dev/null @@ -1,7 +0,0 @@ -// Get focused element hack (works as of 9/4/2020) -// The element in focus has the following css selector qC87s8opH1X3hjuzPoKrl -var ele = document.querySelector(".qC87s8opH1X3hjuzPoKrl"); -// Hack to find the next note. This will break soon. Already broke once... -var prev_ele = ele.parentElement.previousSibling.firstChild; -var id = prev_ele.id.split("_")[0]; -window.location.href = `https://www.evernote.com/client/web?login=true#?fs=false&n=${ id }`; diff --git a/manifest.json b/manifest.json index c8daf02..ba03ea8 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "Evercuts", - "version": "1.11", + "version": "1.12", "description": "Keyboard shortcuts for the new Evernote UI", "permissions": ["activeTab", "declarativeContent"], "background": { @@ -56,12 +56,6 @@ "copyinternalapplink": { "description": "Copy current notes internal app link" }, - "previousNote": { - "description": "Go to the previous note in list" - }, - "nextNote": { - "description": "Go to the next note in list" - }, "newNote": { "description": "Create a new note" }, diff --git a/popup/index.css b/popup/index.css index 7759f6c..9ec8e36 100644 --- a/popup/index.css +++ b/popup/index.css @@ -16,7 +16,7 @@ table.shortcutTable { border: 1px solid rgb(204, 204, 204); color: rgb(204, 204, 204); width: 100%; - font-size: 1.1em; + font-size: 1.2em; } table.shortcutTable td { diff --git a/popup/index.html b/popup/index.html index 866f742..fd15aeb 100644 --- a/popup/index.html +++ b/popup/index.html @@ -8,7 +8,7 @@

Evercuts is active!

-

Default Shortcuts

+

All Shortcuts

From 5614142e07199481f3daf8bdb09217b4f2730eea Mon Sep 17 00:00:00 2001 From: RealP Date: Mon, 25 Oct 2021 22:57:23 -0700 Subject: [PATCH 2/4] Few things in this one commit: * Added a shortcuts for highlight and strikethrough * Started using a commmon file to define functions * Added a linting config and ran linter * Started rework on popup --- .eslintrc.js | 27 +++++++ .gitignore | 1 + content_scripts/background.js | 98 +++++++---------------- content_scripts/contentScript.js | 45 +++++------ content_scripts/helpers.js | 55 +++++++++++++ injectable_actions/clickSearch.js | 22 ++++- injectable_actions/copyInternalAppLink.js | 62 ++------------ injectable_actions/copyInternalWebLink.js | 62 ++------------ injectable_actions/deleteNote.js | 27 +------ injectable_actions/editTags.js | 41 +--------- injectable_actions/highlightText.js | 11 +++ injectable_actions/insertMenu.js | 11 +-- injectable_actions/moveNote.js | 35 +------- injectable_actions/newNote.js | 8 +- injectable_actions/openNote.js | 10 +-- injectable_actions/strikethroughText.js | 5 ++ injectable_actions/toggleFullScreen.js | 8 +- manifest.json | 8 +- popup/index.css | 48 +++++++---- popup/index.html | 4 +- popup/index.js | 33 ++++---- popup/popup.js | 2 +- 22 files changed, 263 insertions(+), 360 deletions(-) create mode 100644 .eslintrc.js create mode 100644 content_scripts/helpers.js create mode 100644 injectable_actions/highlightText.js create mode 100644 injectable_actions/strikethroughText.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..ad51e98 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,27 @@ +module.exports = { + env: { + browser: true, + es2021: true + }, + extends: [ + 'standard' + ], + parserOptions: { + ecmaVersion: 13, + sourceType: 'module' + }, + rules: { + }, + globals: { + // Needs to kept in sync with helpers.js for now + chrome: 'readonly', + mouseOverAndClick: 'readonly', + openMoreActionsMenu: 'readonly', + waitAndClickWebLink: 'readonly', + clickElementAsap: 'readonly', + clickFullScreen: 'readonly', + mouseup: 'readonly', + mousedown: 'readonly', + mouseover: 'readonly' + } +} diff --git a/.gitignore b/.gitignore index 1ac89fa..e057b06 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .temp/ +node_modules/ diff --git a/content_scripts/background.js b/content_scripts/background.js index ca36b18..d2c7d1b 100644 --- a/content_scripts/background.js +++ b/content_scripts/background.js @@ -1,75 +1,35 @@ -chrome.runtime.onInstalled.addListener(function() { - chrome.declarativeContent.onPageChanged.removeRules(undefined, function() { +chrome.runtime.onInstalled.addListener(function () { + chrome.declarativeContent.onPageChanged.removeRules(undefined, function () { chrome.declarativeContent.onPageChanged.addRules([{ conditions: [new chrome.declarativeContent.PageStateMatcher({ - pageUrl: {hostEquals: 'www.evernote.com', schemes: ['https']}, + pageUrl: { hostEquals: 'www.evernote.com', schemes: ['https'] } }) ], - actions: [new chrome.declarativeContent.ShowPageAction()] - }]); - }); -}); + actions: [new chrome.declarativeContent.ShowPageAction()] + }]) + }) +}) + +const keyboardFileMappings = { + search: 'injectable_actions/clickSearch.js', + fullscreen: 'injectable_actions/toggleFullScreen.js', + opennote: 'injectable_actions/openNote.js', + deletenote: 'injectable_actions/deleteNote.js', + movenote: 'injectable_actions/moveNote.js', + copyinternallink: 'injectable_actions/copyInternalWebLink.js', + copyinternalapplink: 'injectable_actions/clickSearch.js', + newNote: 'injectable_actions/newNote.js', + insertMenu: 'injectable_actions/insertMenu.js', + editTags: 'injectable_actions/editTags.js', + strikeThroughText: 'injectable_actions/strikethroughText.js', + highlightText: 'injectable_actions/highlightText.js', + openNoteInNewWindow: 'injectable_actions/highlightText.js' +} chrome.commands.onCommand.addListener(function (command) { - if (command === "search") { - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.executeScript( - tabs[0].id, - {file: "injectable_actions/clickSearch.js"}); - }); - } else if (command === "fullscreen") { - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.executeScript( - tabs[0].id, - {file: "injectable_actions/toggleFullScreen.js"}); - }); - } else if (command === "opennote") { - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.executeScript( - tabs[0].id, - {file: "injectable_actions/openNote.js"}); - }); - } else if (command === "deletenote") { - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.executeScript( - tabs[0].id, - {file: "injectable_actions/deleteNote.js"}); - }); - } else if (command === "movenote") { - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.executeScript( - tabs[0].id, - {file: "injectable_actions/moveNote.js"}); - }); - } else if (command === "copyinternallink") { - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.executeScript( - tabs[0].id, - {file: "injectable_actions/copyInternalWebLink.js"}); - }); - } else if (command === "copyinternalapplink") { - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.executeScript( - tabs[0].id, - {file: "injectable_actions/copyInternalAppLink.js"}); - }); - } else if (command === "newNote") { - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.executeScript( - tabs[0].id, - {file: "injectable_actions/newNote.js"}); - }); - } else if (command === "insertMenu") { - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.executeScript( - tabs[0].id, - {file: "injectable_actions/insertMenu.js"}); - }); - } else if (command === "editTags") { - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.executeScript( - tabs[0].id, - {file: "injectable_actions/editTags.js"}); - }); - } -}); + chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { + chrome.tabs.executeScript( + tabs[0].id, + { file: keyboardFileMappings[command] }) + }) +}) diff --git a/content_scripts/contentScript.js b/content_scripts/contentScript.js index 53dbe28..2fbfb34 100644 --- a/content_scripts/contentScript.js +++ b/content_scripts/contentScript.js @@ -1,26 +1,25 @@ -function getNoteId(element) { - const MAX_PARENTS_TO_CHECK = 4; - var noteId = null; - var currentId = element.id; - - for (var i = 0; i < MAX_PARENTS_TO_CHECK; i++) { - if (currentId.includes("qa-NOTES_SIDEBAR_NOTE")) { - return currentId.split("_")[0]; - } - element = element.parentElement; - currentId = element.id; +function getNoteId (element) { + const MAX_PARENTS_TO_CHECK = 4 + let currentId = element.id + for (let i = 0; i < MAX_PARENTS_TO_CHECK; i++) { + if (currentId.includes('qa-NOTES_SIDEBAR_NOTE')) { + return currentId.split('_')[0] } - return null; + element = element.parentElement + currentId = element.id + } + return null } -document.addEventListener("click", function () { - if (event.altKey === true) { - var id = getNoteId(event.target); - if (id !== null) { - window.open( - `https://www.evernote.com/client/web?login=true#?fs=true&n=${ id }`, - '_blank', - 'left=0,top=0' - ); - } + +document.addEventListener('click', function () { + if (event.altKey === true) { + const id = getNoteId(event.target) + if (id !== null) { + window.open( + `https://www.evernote.com/client/web?login=true#?fs=true&n=${id}`, + '_blank', + 'left=0,top=0' + ) } -}); \ No newline at end of file + } +}) diff --git a/content_scripts/helpers.js b/content_scripts/helpers.js new file mode 100644 index 0000000..8bc8907 --- /dev/null +++ b/content_scripts/helpers.js @@ -0,0 +1,55 @@ +const mouseup = document.createEvent('MouseEvents') +mouseup.initEvent('mouseup', true, true) +const mousedown = document.createEvent('MouseEvents') +mousedown.initEvent('mousedown', true, true) +const mouseover = document.createEvent('MouseEvents') +mouseover.initEvent('mouseover', true, true) + +function mouseOverAndClick (ele) { + ele.dispatchEvent(mouseover) + ele.click() +} + +export function waitAndClickWebLink (link) { + const MAX_WAIT = 1 * 1000 // 1 seconds seems like plenty + const interval = 5 // 5ms between checks + let curWait = 0 + const checkExist = setInterval(function () { + curWait += interval + if (curWait > MAX_WAIT) { + clearInterval(checkExist) + alert('Failed') + } + const ele = document.getElementById(link) + if (ele) { + clearInterval(checkExist) + mouseOverAndClick(ele) + } + }, interval) +} + +export function openMoreActionsMenu () { + const button = document.getElementById('qa-NOTE_ACTIONS').parentElement + button.dispatchEvent(mouseup) +} + +export function clickElementAsap (ele, timeout = 2000, interval = 10) { + let curWait = 0 + const checkExist = setInterval(function () { + curWait += interval + if (curWait >= timeout) { + clearInterval(checkExist) + console.log('Failed to click ' + ele) + } + const clickableElement = document.getElementById(ele) + if (clickableElement) { + clearInterval(checkExist) + mouseOverAndClick(clickableElement) + } + }, interval) +} + +export function clickFullScreen () { + const button = document.getElementById('qa-NOTE_FULLSCREEN_BTN') + button.dispatchEvent(mousedown) +} diff --git a/injectable_actions/clickSearch.js b/injectable_actions/clickSearch.js index f5ecfee..859ff55 100644 --- a/injectable_actions/clickSearch.js +++ b/injectable_actions/clickSearch.js @@ -1,5 +1,19 @@ -function clickSearch() { - var button = document.getElementById("qa-SEARCH_BAR_INITIAL"); - button.click(); +/** + * Evernote has this quirk in the url where the search params are split by a # + * the only search param before the # is login which I always assume to be true +*/ +function getSearchParams (url) { + return url.split('#')[1].slice(1) } -clickSearch(); +function isFullScreen () { + const urlParams = new URLSearchParams(getSearchParams(window.location.toString())) + return urlParams.get('fs') +} +function clickSearch () { + if (isFullScreen()) { + clickFullScreen() + } + const button = document.getElementById('qa-SEARCH_BAR_INITIAL') + button.click() +} +clickSearch() diff --git a/injectable_actions/copyInternalAppLink.js b/injectable_actions/copyInternalAppLink.js index bac1f0c..cb5e5b7 100644 --- a/injectable_actions/copyInternalAppLink.js +++ b/injectable_actions/copyInternalAppLink.js @@ -1,57 +1,7 @@ -function mouseOverAndClick(ele) { - var evt = document.createEvent("MouseEvents"); - evt.initEvent("mouseover", true, true); - ele.dispatchEvent(evt); - ele.click(); +function copyInternalAppLink () { + openMoreActionsMenu() + const ele = document.getElementById('qa-ACTION_COPY_INTERNAL_LINK') + ele.dispatchEvent(mouseover) + clickElementAsap('qa-ACTION_COPY_APP_LINK') } - -function waitAndClickWebLink(link) { - const MAX_WAIT = 2 * 1000; // 2 seconds seems like plenty - const interval = 10; // 10ms between checks - var cur_wait = 0; - var checkExist = setInterval(function() { - cur_wait += interval; - if (cur_wait > MAX_WAIT) { - clearInterval(checkExist); - alert("Failed"); - } - var ele = document.getElementById(link); - if (ele) { - clearInterval(checkExist); - mouseOverAndClick(ele); - } - }, interval); -} - -function openMoreActionsMenu() { - const evt = document.createEvent("MouseEvents"); - evt.initEvent("mouseup", true, true); - const button = document.getElementById("qa-NOTE_ACTIONS").parentElement; - button.dispatchEvent(evt); -} - -function copyInternalWebLink() { - const MAX_WAIT = 2 * 1000; - const interval = 10; - const INTERNAL_LINK_ID = 'qa-ACTION_COPY_INTERNAL_LINK'; - var evt = document.createEvent("MouseEvents"); - evt.initEvent("mouseover", true, true); - var cur_wait = 0; - - var checkExist = setInterval(function() { - cur_wait += interval; - if (cur_wait > MAX_WAIT) { - clearInterval(checkExist); - alert("Failed"); - } - var ele = document.getElementById(INTERNAL_LINK_ID); - if (ele) { - clearInterval(checkExist); - ele.dispatchEvent(evt); - waitAndClickWebLink('qa-ACTION_COPY_APP_LINK'); - } - }, interval); -} - -openMoreActionsMenu(); -copyInternalWebLink(); +copyInternalAppLink() diff --git a/injectable_actions/copyInternalWebLink.js b/injectable_actions/copyInternalWebLink.js index 7da9e95..df3a1fa 100644 --- a/injectable_actions/copyInternalWebLink.js +++ b/injectable_actions/copyInternalWebLink.js @@ -1,57 +1,7 @@ -function mouseOverAndClick(ele) { - var evt = document.createEvent("MouseEvents"); - evt.initEvent("mouseover", true, true); - ele.dispatchEvent(evt); - ele.click(); +function copyInternalWebLink () { + openMoreActionsMenu() + const ele = document.getElementById('qa-ACTION_COPY_INTERNAL_LINK') + ele.dispatchEvent(mouseover) + clickElementAsap('qa-ACTION_COPY_WEB_LINK') } - -function waitAndClickWebLink(link) { - const MAX_WAIT = 2 * 1000; // 2 seconds seems like plenty - const interval = 10; // 10ms between checks - var cur_wait = 0; - var checkExist = setInterval(function() { - cur_wait += interval; - if (cur_wait > MAX_WAIT) { - clearInterval(checkExist); - alert("Failed"); - } - var ele = document.getElementById(link); - if (ele) { - clearInterval(checkExist); - mouseOverAndClick(ele); - } - }, interval); -} - -function openMoreActionsMenu() { - const evt = document.createEvent("MouseEvents"); - evt.initEvent("mouseup", true, true); - const button = document.getElementById("qa-NOTE_ACTIONS").parentElement; - button.dispatchEvent(evt); -} - -function copyInternalWebLink() { - const MAX_WAIT = 2 * 1000; - const interval = 10; - const INTERNAL_LINK_ID = 'qa-ACTION_COPY_INTERNAL_LINK'; - var evt = document.createEvent("MouseEvents"); - evt.initEvent("mouseover", true, true); - var cur_wait = 0; - - var checkExist = setInterval(function() { - cur_wait += interval; - if (cur_wait > MAX_WAIT) { - clearInterval(checkExist); - alert("Failed"); - } - var ele = document.getElementById(INTERNAL_LINK_ID); - if (ele) { - clearInterval(checkExist); - ele.dispatchEvent(evt); - waitAndClickWebLink('qa-ACTION_COPY_WEB_LINK'); - } - }, interval); -} - -openMoreActionsMenu(); -copyInternalWebLink(); +copyInternalWebLink() diff --git a/injectable_actions/deleteNote.js b/injectable_actions/deleteNote.js index 46f1789..09c7992 100644 --- a/injectable_actions/deleteNote.js +++ b/injectable_actions/deleteNote.js @@ -1,25 +1,2 @@ -function clickElementAsap(ele, timeout=2000, interval=10) { - var cur_wait = 0; - var checkExist = setInterval(function() { - cur_wait += interval; - if (cur_wait >= timeout) { - clearInterval(checkExist); - console.log("Failed to click " + ele); - } - var clickableElement = document.getElementById(ele); - if (clickableElement) { - clearInterval(checkExist); - clickableElement.click(); - } - }, interval); -} - -function openMoreActionsMenu() { - var evt = document.createEvent("MouseEvents"); - evt.initEvent("mouseup", true, true); - const button = document.getElementById("qa-NOTE_ACTIONS").parentElement; - button.dispatchEvent(evt); -} - -openMoreActionsMenu(); -clickElementAsap('qa-ACTION_DELETE'); +openMoreActionsMenu() +clickElementAsap('qa-ACTION_DELETE') diff --git a/injectable_actions/editTags.js b/injectable_actions/editTags.js index 07949f8..8cbde31 100644 --- a/injectable_actions/editTags.js +++ b/injectable_actions/editTags.js @@ -1,38 +1,3 @@ -function clickEditTags () { - const el = document.getElementById('qa-ACTION_EDIT_TAGS'); - el.click(); -} -function mouseOverAndClick(ele) { - var evt = document.createEvent("MouseEvents"); - evt.initEvent("mouseover", true, true); - ele.dispatchEvent(evt); - ele.click(); -} - -function openMoreActionsMenu() { - var evt = document.createEvent("MouseEvents"); - evt.initEvent("mouseup", true, true); - const button = document.getElementById("qa-NOTE_ACTIONS").parentElement; - button.dispatchEvent(evt); -} - -function clickElementAsap(ele, timeout=2000, interval=10) { - var cur_wait = 0; - var checkExist = setInterval(function() { - cur_wait += interval; - if (cur_wait >= timeout) { - clearInterval(checkExist); - console.log("Failed to click " + ele); - } - var clickableElement = document.getElementById(ele); - if (clickableElement) { - clearInterval(checkExist); - mouseOverAndClick(clickableElement); - document.getElementById('qa-TAG_FILTER_INPUT').focus(); - } - }, interval); -} - -openMoreActionsMenu(); -clickElementAsap('qa-ACTION_EDIT_TAGS'); -mouseOverAndClick(document.getElementById('qa-TAG_FILTER_INPUT')); +openMoreActionsMenu() +clickElementAsap('qa-ACTION_EDIT_TAGS') +mouseOverAndClick(document.getElementById('qa-TAG_FILTER_INPUT')) diff --git a/injectable_actions/highlightText.js b/injectable_actions/highlightText.js new file mode 100644 index 0000000..c500414 --- /dev/null +++ b/injectable_actions/highlightText.js @@ -0,0 +1,11 @@ +function openHighlightText () { + const button = document.getElementById('qa-HIGHLIGHT_TEXT_BTN') + // This svg element has 3 classes when highlighted and 2 when not + const isHiglighted = button.children[0].classList.length > 2 + if (!isHiglighted) { + button.dispatchEvent(mouseup) + waitAndClickWebLink('qa-YELLOW_COLOR_LABEL') + } + // Unhighlighting is harder to do right now programatically +} +openHighlightText() diff --git a/injectable_actions/insertMenu.js b/injectable_actions/insertMenu.js index c82c451..f3f9595 100644 --- a/injectable_actions/insertMenu.js +++ b/injectable_actions/insertMenu.js @@ -1,8 +1,5 @@ -function openInsertMenu() { - var evt = document.createEvent("MouseEvents"); - evt.initEvent("mouseup", true, true); - const button = document.getElementById("qa-INSERT_DROPDOWN"); - button.dispatchEvent(evt); +function openInsertMenu () { + const button = document.getElementById('qa-INSERT_DROPDOWN') + button.dispatchEvent(mouseup) } - -openInsertMenu(); +openInsertMenu() diff --git a/injectable_actions/moveNote.js b/injectable_actions/moveNote.js index 0059484..1013e00 100644 --- a/injectable_actions/moveNote.js +++ b/injectable_actions/moveNote.js @@ -1,33 +1,2 @@ -function mouseOverAndClick(ele) { - var evt = document.createEvent("MouseEvents"); - evt.initEvent("mouseover", true, true); - ele.dispatchEvent(evt); - ele.click(); -} - -function clickElementAsap(ele, timeout=2000, interval=10) { - var cur_wait = 0; - var checkExist = setInterval(function() { - cur_wait += interval; - if (cur_wait >= timeout) { - clearInterval(checkExist); - console.log("Failed to click " + ele); - } - var clickableElement = document.getElementById(ele); - if (clickableElement) { - clearInterval(checkExist); - mouseOverAndClick(clickableElement); - } - }, interval); -} - - -function openMoreActionsMenu() { - var evt = document.createEvent("MouseEvents"); - evt.initEvent("mouseup", true, true); - const button = document.getElementById("qa-NOTE_ACTIONS").parentElement; - button.dispatchEvent(evt); -} - -openMoreActionsMenu(); -clickElementAsap('qa-ACTION_MOVE'); +openMoreActionsMenu() +clickElementAsap('qa-ACTION_MOVE') diff --git a/injectable_actions/newNote.js b/injectable_actions/newNote.js index fe339dc..f9267e1 100644 --- a/injectable_actions/newNote.js +++ b/injectable_actions/newNote.js @@ -1,5 +1,5 @@ -function newNote() { - const button = document.getElementById("qa-CREATE_NOTE"); - button.click(); +function newNote () { + const button = document.getElementById('qa-CREATE_NOTE') + button.click() } -newNote(); +newNote() diff --git a/injectable_actions/openNote.js b/injectable_actions/openNote.js index a876252..2c30c70 100644 --- a/injectable_actions/openNote.js +++ b/injectable_actions/openNote.js @@ -1,6 +1,6 @@ -function openNote() { - const urlParams = new URLSearchParams(window.location.toString()); - var newURL = `https://www.evernote.com/client/web?login=true#?fs=true&n=${ urlParams.get("n") }` - window.open(newURL, '_blank', ''); +function openNote () { + const urlParams = new URLSearchParams(window.location.toString()) + const newURL = `https://www.evernote.com/client/web?login=true#?fs=true&n=${urlParams.get('n')}` + window.open(newURL, '_blank', 'left=0,top=0') } -openNote(); +openNote() diff --git a/injectable_actions/strikethroughText.js b/injectable_actions/strikethroughText.js new file mode 100644 index 0000000..b63eac5 --- /dev/null +++ b/injectable_actions/strikethroughText.js @@ -0,0 +1,5 @@ +function clickStrikethrough () { + const button = document.getElementById('qa-STRIKETHROUGH_TEXT_BTN') + button.click() +} +clickStrikethrough() diff --git a/injectable_actions/toggleFullScreen.js b/injectable_actions/toggleFullScreen.js index da067d1..89ce628 100644 --- a/injectable_actions/toggleFullScreen.js +++ b/injectable_actions/toggleFullScreen.js @@ -1,7 +1 @@ -function clickFullScreen() { - let evt = document.createEvent("MouseEvents"); - evt.initEvent("mousedown", true, true); - const button = document.getElementById("qa-NOTE_FULLSCREEN_BTN"); - button.dispatchEvent(evt); -} -clickFullScreen(); +clickFullScreen() diff --git a/manifest.json b/manifest.json index ba03ea8..f7c6cfe 100644 --- a/manifest.json +++ b/manifest.json @@ -65,6 +65,12 @@ "editTags": { "description": "Edit the current notes tags" }, + "strikeThroughText": { + "description": "Click on strike through text" + }, + "highlightText": { + "description": "Highlight selected text (yellow)" + }, "_execute_page_action": { "description": "Show shorcuts and options" } @@ -72,7 +78,7 @@ "content_scripts": [ { "matches": ["https://*.evernote.com/*"], - "js": ["content_scripts/contentScript.js"] + "js": ["content_scripts/contentScript.js", "content_scripts/helpers.js"] } ], "manifest_version": 2 diff --git a/popup/index.css b/popup/index.css index 9ec8e36..744d13b 100644 --- a/popup/index.css +++ b/popup/index.css @@ -1,32 +1,37 @@ +html { + width: 800px; + height: 600px; + /*padding: 5px;*/ + font-size: 1.5em; +} + body { - background-color: black; - width: 630px; - height: 390px; - padding: 5px; + background-color: #262626; + overflow: hidden; } - -h1,h2 { - margin-top: 0; +h3 { + margin: 0; + color: #00a82d; +} +h2 { + color: #f2f2f2; text-align: center; - color: rgb(204, 204, 204); } - table.shortcutTable { border-collapse: collapse; - border: 1px solid rgb(204, 204, 204); - color: rgb(204, 204, 204); + border: 1px solid #f2f2f2; + color: #f2f2f2; width: 100%; - font-size: 1.2em; } table.shortcutTable td { width: 50%; - border: 1px solid rgb(204, 204, 204); + border: 1px solid #f2f2f2; } .headerRow { background-color: rgb(77, 77, 77); - color: rgb(204, 204, 204); + color: #f2f2f2; } .headerCell { @@ -37,6 +42,19 @@ table.shortcutTable td { position: relative; bottom: 0; width: 100%; - color: rgb(204, 204, 204); + color: #f2f2f2; text-align: center; } + +.button { + background-color: #00a82d; + border: none; + border-radius: 10px; + color: #003013; + padding: 10px 10px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 1.1em; + cursor: pointer; +} diff --git a/popup/index.html b/popup/index.html index fd15aeb..3b6c73d 100644 --- a/popup/index.html +++ b/popup/index.html @@ -7,7 +7,8 @@ -

Evercuts is active!

+

Evercuts is active!

+

All Shortcuts

@@ -18,7 +19,6 @@

All Shortcuts

diff --git a/popup/index.js b/popup/index.js index b3830cb..2240f8c 100644 --- a/popup/index.js +++ b/popup/index.js @@ -1,21 +1,26 @@ window.onload = (event) => { - let table = document.getElementById("shortcutTable"); - let rowIdx = 0; + const table = document.getElementById('shortcutTable') + let rowIdx = 0 chrome.commands.getAll(function (commands) { for (let i = 0; i <= commands.length; i++) { - if (commands[i]["description"] === "") { - commands[i]["description"] = "Show this popup"; + if (commands[i].description === '') { + commands[i].description = 'Show this popup' } - let row = table.insertRow(rowIdx + 1); - let cell1 = row.insertCell(0); - let cell2 = row.insertCell(1); - cell1.innerHTML = commands[i]["description"]; - if (commands[i]["shortcut"]) { - cell2.innerHTML = commands[i]["shortcut"]; + const row = table.insertRow(rowIdx + 1) + const cell1 = row.insertCell(0) + const cell2 = row.insertCell(1) + cell1.innerHTML = commands[i].description + if (commands[i].shortcut) { + cell2.innerHTML = commands[i].shortcut } else { - cell2.innerHTML = "Click button below to configure"; + cell2.innerHTML = 'Click button below to configure' } - rowIdx += 1; + rowIdx += 1 } - }); -}; + }) + const row = table.insertRow(rowIdx + 1) + const cell1 = row.insertCell(0) + const cell2 = row.insertCell(1) + cell1.innerHTML = 'Open note in a new window' + cell2.innerHTML = 'Alt + Click on note to open' +} diff --git a/popup/popup.js b/popup/popup.js index d73e7a7..fcfb80c 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -1,3 +1,3 @@ document.getElementById('hotkey').onclick = () => chrome.tabs.create({ url: 'chrome://extensions/configureCommands' -}); +}) From 18643884e1e610bcdbfad8a8b778dd85c63019dc Mon Sep 17 00:00:00 2001 From: Paul Pfeffer Date: Thu, 2 Dec 2021 20:48:18 -0800 Subject: [PATCH 3/4] Fix some things up --- content_scripts/background.js | 2 +- content_scripts/helpers.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/content_scripts/background.js b/content_scripts/background.js index d2c7d1b..db95def 100644 --- a/content_scripts/background.js +++ b/content_scripts/background.js @@ -17,7 +17,7 @@ const keyboardFileMappings = { deletenote: 'injectable_actions/deleteNote.js', movenote: 'injectable_actions/moveNote.js', copyinternallink: 'injectable_actions/copyInternalWebLink.js', - copyinternalapplink: 'injectable_actions/clickSearch.js', + copyinternalapplink: 'injectable_actions/copyInternalAppLink.js', newNote: 'injectable_actions/newNote.js', insertMenu: 'injectable_actions/insertMenu.js', editTags: 'injectable_actions/editTags.js', diff --git a/content_scripts/helpers.js b/content_scripts/helpers.js index 8bc8907..fb1f95d 100644 --- a/content_scripts/helpers.js +++ b/content_scripts/helpers.js @@ -10,7 +10,7 @@ function mouseOverAndClick (ele) { ele.click() } -export function waitAndClickWebLink (link) { +function waitAndClickWebLink (link) { const MAX_WAIT = 1 * 1000 // 1 seconds seems like plenty const interval = 5 // 5ms between checks let curWait = 0 @@ -18,7 +18,7 @@ export function waitAndClickWebLink (link) { curWait += interval if (curWait > MAX_WAIT) { clearInterval(checkExist) - alert('Failed') + alert('Evercuts had an error please email me') } const ele = document.getElementById(link) if (ele) { @@ -28,12 +28,12 @@ export function waitAndClickWebLink (link) { }, interval) } -export function openMoreActionsMenu () { +function openMoreActionsMenu () { const button = document.getElementById('qa-NOTE_ACTIONS').parentElement button.dispatchEvent(mouseup) } -export function clickElementAsap (ele, timeout = 2000, interval = 10) { +function clickElementAsap (ele, timeout = 2000, interval = 10) { let curWait = 0 const checkExist = setInterval(function () { curWait += interval @@ -49,7 +49,7 @@ export function clickElementAsap (ele, timeout = 2000, interval = 10) { }, interval) } -export function clickFullScreen () { +function clickFullScreen () { const button = document.getElementById('qa-NOTE_FULLSCREEN_BTN') - button.dispatchEvent(mousedown) + mouseOverAndClick(button) } From 640f81316134e16422713617ceb9b7ed81ecee4f Mon Sep 17 00:00:00 2001 From: Paul Pfeffer Date: Tue, 25 Jul 2023 21:20:57 -0700 Subject: [PATCH 4/4] very old stuff don't know what it does --- popup/index.css | 40 +++++++++++++++------------------------- popup/index.html | 6 ++---- popup/index.js | 8 +++++++- popup/popup.js | 3 --- 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/popup/index.css b/popup/index.css index 744d13b..0d59723 100644 --- a/popup/index.css +++ b/popup/index.css @@ -1,32 +1,23 @@ html { width: 800px; - height: 600px; - /*padding: 5px;*/ + height: 100%; font-size: 1.5em; -} +} body { background-color: #262626; overflow: hidden; } -h3 { - margin: 0; - color: #00a82d; -} + h2 { color: #f2f2f2; text-align: center; } -table.shortcutTable { - border-collapse: collapse; - border: 1px solid #f2f2f2; - color: #f2f2f2; - width: 100%; -} -table.shortcutTable td { - width: 50%; - border: 1px solid #f2f2f2; +.centeredContainer { + display: flex; + align-items: center; + justify-content: center; } .headerRow { @@ -34,19 +25,18 @@ table.shortcutTable td { color: #f2f2f2; } -.headerCell { - width: 50%; +table.shortcutTable { + border-collapse: collapse; + color: #f2f2f2; + width: 100%; } -.footer { - position: relative; - bottom: 0; - width: 100%; - color: #f2f2f2; - text-align: center; +table.shortcutTable td { + width: 50%; + border: 1px solid #f2f2f2; } -.button { +button.button { background-color: #00a82d; border: none; border-radius: 10px; diff --git a/popup/index.html b/popup/index.html index 3b6c73d..f28e75f 100644 --- a/popup/index.html +++ b/popup/index.html @@ -7,8 +7,6 @@ -

Evercuts is active!

-

All Shortcuts

@@ -18,8 +16,8 @@

All Shortcuts

-