From c4178dc2daa10da5add9e3e37b8887305cdce91f Mon Sep 17 00:00:00 2001 From: Adam Thompson-Sharpe Date: Tue, 11 Feb 2020 22:32:51 -0500 Subject: [PATCH] Added support for Bing Typing Test and normalized variable names. --- README.md | 6 ++- typecheat-button.js | 82 ++++++++++++++++++++++++++++++----------- typecheat-button.min.js | 2 +- typecheat.js | 74 ++++++++++++++++++++++++++----------- typecheat.min.js | 2 +- 5 files changed, 119 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index b955a60..10b5dff 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ As of now, the sites that work are: - [10FastFingers](https://10fastfingers.com/) (Normal tests and [custom text](https://10fastfingers.com/text-practice/new)) - [TypeRacer](https://play.typeracer.com/) - [TypingTestNow](https://typingtestnow.com/) +- [Bing Typing Test](https://www.bing.com/search?q=typing+test) I am planning to add support for more. @@ -30,6 +31,7 @@ If you go too fast, an alert box will appear saying that they believe you have c ### If you're using `typecheat-button.min.js` On **10FastFingers**, the button appears just **below** the text field. On **TypeRacer**, the button appears **in the navbar** above the "Blog, Forum, Pit Stop, About" buttons. -On **TypingTestNow**, the button appears at the **top of the page** just under the navbar. +On **TypingTestNow**, the button appears at the **top of the page** just under the navbar. +On **Bing Typing Test**, the button appears in the typing test item **to the right of** the "Typing test" heading. -**Note: On 10FastFingers, if you end up going through the entire text, the words will continue to autofill. If you continue to press space it can cause you to get incorrect words marked, despite the text being over.** \ No newline at end of file +**Note: On 10FastFingers, if you end up going through the entire text, the words will continue to autofill. If you continue to press space it can cause you to get incorrect words marked, despite the text being over.** diff --git a/typecheat-button.js b/typecheat-button.js index 8b9aaac..8f9b657 100644 --- a/typecheat-button.js +++ b/typecheat-button.js @@ -46,20 +46,26 @@ if(url == "10fastfingers.com" || url == "www.10fastfingers.com") { } else if(url == "typingtestnow.com" || url == "www.typingtestnow.com") { console.log("~~~~~~~~~~~~~~~~~~~\n TypeCheat Active! \nSite: TypingTestNow\n~~~~~~~~~~~~~~~~~~~"); site = 2; +} else if(url == "www.bing.com" || url == "bing.com") { + console.log("~~~~~~~~~~~~~~~~~~~\n TypeCheat Active! \nSite: Bing Test\n~~~~~~~~~~~~~~~~~~~"); + site = 3; } +// Variables +let tText, tWords, cWord, tField; + // 10FastFingers Cheat Code function tenFastCheat() { // Generate wordlist - let tText = document.getElementById("row1"); - let tWords = []; + tText = document.getElementById("row1"); + tWords = []; for(let i = 0; i < tText.children.length; i++) { tWords.push(tText.children[i].innerText); } // Interval - let cWord = 0; + cWord = 0; // Different method for different modes - let tField = null; + tField = null; if(altMode == 0) { tField = document.getElementById("inputfield"); } else if(altMode == 1) { @@ -78,15 +84,15 @@ function tenFastCheat() { // TypeRacer Cheat Code function typeRacerCheat() { // Generate wordlist - let textElement = document.querySelector("#gwt-uid-15 > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td"); - let wordlist = textElement.innerText.split(" "); + tText = document.querySelector("#gwt-uid-15 > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td"); + tWords = tText.innerText.split(" "); // Interval - let crWord = 0; - let textField = document.querySelector("#gwt-uid-15 > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td > input"); - textField.addEventListener("keydown", function(e) { + cWord = 0; + tField = document.querySelector("#gwt-uid-15 > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td > input"); + tField.addEventListener("keydown", function(e) { if(e.keyCode == 32) { - textField.value = wordlist[crWord]; - crWord++; + tField.value = tWords[cWord]; + cWord++; } }); // Change button colour to show that it has activated @@ -96,26 +102,55 @@ function typeRacerCheat() { // TypingTestNow Cheat Code function typingTestNowCheat() { // Generate wordlist - let text = document.getElementsByClassName("sample-text")[0]; - let words = []; - for(let i = 0; i < text.children.length; i++) { - for(let j = 0; j < text.children[i].children.length; j++) { - words.push(text.children[i].children[j].innerText); + tText = document.getElementsByClassName("sample-text")[0]; + tWords = []; + for(let i = 0; i < tText.children.length; i++) { + for(let j = 0; j < tText.children[i].children.length; j++) { + words.push(tText.children[i].children[j].innerText); } } // Interval - var i = 0; - let field = document.getElementById("practice-input"); - field.addEventListener("keydown", function(e) { + cWord = 0; + tField = document.getElementById("practice-input"); + tField.addEventListener("keydown", function(e) { if(e.keyCode == 32) { - field.value = words[i]; - i++; + tField.value = tWords[cWord]; + cWord++; } }); // Change button colour to show that it has activated document.getElementsByClassName("row")[0].children[0].style = "width: 100%; color: #0F0;"; } +// Bing Typing Test Cheat Code +function bingCheat() { + // Generate wordlist + tText = document.getElementById("edu_promptText"); + tWords = []; + let workWord = ""; + for(let i = 0; i < tText.children.length; i++) { + for(let j = 0; j < tText.children[i].children.length; j++) { + if(tText.children[i].children[j].className == "space") { + tWords.push(workWord); + workWord = ""; + } else { + workWord += tText.children[i].children[j].innerText; + } + } + } + // Interval + cWord = 0; + tField = document.getElementById("edu_inputText"); + tField.addEventListener("keydown", function(e) { + if(e.keyCode == 32) { + tField.value += tWords[cWord]; + cWord++; + } + }); + // Change button colour to show that it has activated + document.getElementById("edu_answer").children[0].children[0].getElementsByTagName("button")[0].style = "color: #0F0;"; +} + // Cheat switch(site) { // 10FastFingers (Normal) @@ -133,4 +168,9 @@ switch(site) { // Create cheat button document.getElementsByClassName("row")[0].innerHTML = "" break; + // Bing Typing Test + case 3: + // Create cheat button + document.getElementById("edu_answer").children[0].children[0].innerHTML += ""; + break; } \ No newline at end of file diff --git a/typecheat-button.min.js b/typecheat-button.min.js index 18f593c..d85e5ef 100644 --- a/typecheat-button.min.js +++ b/typecheat-button.min.js @@ -15,4 +15,4 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -var url=window.location.href.split("/")[2],site=-1,altMode=0;function tenFastCheat(){for(var e=document.getElementById("row1"),t=[],n=0;n table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td").innerText.split(" "),n=0,o=document.querySelector("#gwt-uid-15 > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td > input");o.addEventListener("keydown",function(e){32==e.keyCode&&(o.value=t[n],n++)}),document.getElementsByClassName("navigation")[0].children[0].style="width: 100%; color: #0F0;"}function typingTestNowCheat(){for(var e=document.getElementsByClassName("sample-text")[0],t=[],n=0;n table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td"),tWords=tText.innerText.split(" "),cWord=0,(tField=document.querySelector("#gwt-uid-15 > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td > input")).addEventListener("keydown",function(e){32==e.keyCode&&(tField.value=tWords[cWord],cWord++)}),document.getElementsByClassName("navigation")[0].children[0].style="width: 100%; color: #0F0;"}function typingTestNowCheat(){tText=document.getElementsByClassName("sample-text")[0],tWords=[];for(var e=0;e table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td"); - let wordlist = textElement.innerText.split(" "); + tText = document.querySelector("#gwt-uid-15 > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td"); + tWords = tText.innerText.split(" "); // Interval - let crWord = 0; - let textField = document.querySelector("#gwt-uid-15 > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td > input"); - textField.addEventListener("keydown", function(e) { + cWord = 0; + tField = document.querySelector("#gwt-uid-15 > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td > input"); + tField.addEventListener("keydown", function(e) { if(e.keyCode == 32) { - textField.value = wordlist[crWord]; - crWord++; + tField.value = tWords[cWord]; + cWord++; } }); break; // TypingTestNow case 2: // Generate wordlist - let text = document.getElementsByClassName("sample-text")[0]; - let words = []; - for(let i = 0; i < text.children.length; i++) { - for(let j = 0; j < text.children[i].children.length; j++) { - words.push(text.children[i].children[j].innerText); + tText = document.getElementsByClassName("sample-text")[0]; + tWords = []; + for(let i = 0; i < tText.children.length; i++) { + for(let j = 0; j < tText.children[i].children.length; j++) { + words.push(tText.children[i].children[j].innerText); } } // Interval - let i = 0; - let field = document.getElementById("practice-input"); - field.addEventListener("keydown", function(e) { + cWord = 0; + tField = document.getElementById("practice-input"); + tField.addEventListener("keydown", function(e) { if(e.keyCode == 32) { - field.value = words[i]; - i++; + tField.value = tWords[cWord]; + cWord++; } }); break; + // Bing Typing Test + case 3: + // Generate wordlist + tText = document.getElementById("edu_promptText"); + tWords = []; + let workWord = ""; + for(let i = 0; i < tText.children.length; i++) { + for(let j = 0; j < tText.children[i].children.length; j++) { + if(tText.children[i].children[j].className == "space") { + tWords.push(workWord); + workWord = ""; + } else { + workWord += tText.children[i].children[j].innerText; + } + } + } + // Interval + cWord = 0; + tField = document.getElementById("edu_inputText"); + tField.addEventListener("keydown", function(e) { + if(e.keyCode == 32) { + tField.value += tWords[cWord]; + cWord++; + } + }); } \ No newline at end of file diff --git a/typecheat.min.js b/typecheat.min.js index 8823b95..817bd5d 100644 --- a/typecheat.min.js +++ b/typecheat.min.js @@ -15,4 +15,4 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -var url=window.location.href.split("/")[2],site=-1,altMode=0;switch("10fastfingers.com"==url||"www.10fastfingers.com"==url?(console.log("~~~~~~~~~~~~~~~~~~~\n TypeCheat Active! \nSite: 10FastFingers\n~~~~~~~~~~~~~~~~~~~"),site=0,"text"==window.location.href.split("/")[3]&&(altMode=1)):"play.typeracer.com"==url||"typeracer.com"==url?(console.log("~~~~~~~~~~~~~~~~~~~\n TypeCheat Active! \nSite: TypeRacer\n~~~~~~~~~~~~~~~~~~~"),site=1):"typingtestnow.com"!=url&&"www.typingtestnow.com"!=url||(console.log("~~~~~~~~~~~~~~~~~~~\n TypeCheat Active! \nSite: TypingTestNow\n~~~~~~~~~~~~~~~~~~~"),site=2),site){case 0:console.log("BROKEN");for(var tText=document.getElementById("row1"),tWords=[],i=0;i table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td"),wordlist=textElement.innerText.split(" "),crWord=0,textField=document.querySelector("#gwt-uid-15 > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td > input");textField.addEventListener("keydown",function(e){32==e.keyCode&&(textField.value=wordlist[crWord],crWord++)});break;case 2:var text=document.getElementsByClassName("sample-text")[0],words=[];for(i=0;i table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td"),tWords=tText.innerText.split(" "),cWord=0,(tField=document.querySelector("#gwt-uid-15 > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td > input")).addEventListener("keydown",function(e){32==e.keyCode&&(tField.value=tWords[cWord],cWord++)});break;case 2:tText=document.getElementsByClassName("sample-text")[0],tWords=[];for(i=0;i