├── README.md ├── LICENSE └── ripper.js /README.md: -------------------------------------------------------------------------------- 1 | # CheggRipper 2 | This script gets the Chegg solutions for any given textbook and outputs all of them to a simple html document. 3 | It is intended to be automatic, once I get it to work that way but for now you can: 4 | 5 | Find a textbook you want all the solutions for and navigate to the first question in the first chapter. 6 | In chrome console, copy/paste the two functions at the top and enter them into the console. 7 | Then follow the directions in the script. 8 | 9 | **DISCLAIMER: For educational purposes only. Proof of concept only, use responsibly** 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Elby Basolis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ripper.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ripper.js - a script to grab solutions from chegg 3 | * By Elbert Basolis (elby@basolis.com) 4 | * https://github.com/elby22/CheggRipper 5 | * 6 | * Disclaimer: I assume no responsibility for the use of this software. 7 | * This is a proof cof concept only not intended to infringe copyright or violate any laws anywhere. 8 | */ 9 | 10 | //Clones the canvas 11 | function cloneCanvas(oldCanvas) { 12 | 13 | //create a new canvas 14 | var newCanvas = document.createElement('canvas'); 15 | var context = newCanvas.getContext('2d'); 16 | 17 | //set dimensions 18 | newCanvas.width = oldCanvas.width; 19 | newCanvas.height = oldCanvas.height; 20 | 21 | //apply the old canvas to the new one 22 | context.drawImage(oldCanvas, 0, 0); 23 | 24 | //return the new canvas 25 | return newCanvas; 26 | } 27 | 28 | //Main logic: gets all the good stuff from the page, and advances to the next 29 | function ripPage(){ 30 | //Get next Chapter/Problem text 31 | var nextProblem = $('.next-problem-label').text(); 32 | 33 | //Get all html for the problem 34 | var steps = $('.solution-player-steps').children(); 35 | for(var i = 0; i < steps.size(); i++){ 36 | 37 | //This only works for non-canvas elements 38 | var stepInfo = $(steps[i]).find(".step-content").children().first(); 39 | 40 | 41 | if($(stepInfo[0]).html() === ""){ 42 | $(newDoc.body).append(cloneCanvas(stepInfo[0])); 43 | $(newDoc.body).append("
"); 44 | }else{ 45 | $(newDoc.body).append(stepInfo.html()); 46 | } 47 | } 48 | 49 | //Add next problem header 50 | $(newDoc.body).append('

' + nextProblem + '


'); 51 | 52 | console.log("next problem" + nextProblem); 53 | //Its probably gonna have more than 1 problem in the book 54 | $('.next-problem').click(); 55 | } 56 | 57 | /* 58 | *Run these lines first 59 | */ 60 | 61 | //New doc to put this info in 62 | var impl = document.implementation; 63 | var newDoc = impl.createHTMLDocument("Chegg output"); 64 | 65 | $(newDoc.body).append('

FIRST PROBLEM

'); 66 | 67 | 68 | /* 69 | *Run the ripPage() function as many times as you want 70 | *Then run the last two lines to generate the new document 71 | */ 72 | 73 | //Write new document to screen 74 | newDoc.body.style.margin = "10px 10px 10px 10px"; 75 | document.body = newDoc.body; --------------------------------------------------------------------------------