Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

WARNING!!! #1

Closed
ghost opened this issue Oct 20, 2019 · 28 comments
Closed

WARNING!!! #1

ghost opened this issue Oct 20, 2019 · 28 comments

Comments

@ghost
Copy link

ghost commented Oct 20, 2019

I think this userscript will stop working, because they are changing the pupilpath script because its been glitching.

@KaBankz
Copy link
Owner

KaBankz commented Oct 20, 2019

Unfortunately, if it does stop working I will no longer be able to fix it because I no longer have access to my pupilpath account.

@KaBankz KaBankz closed this as completed Oct 20, 2019
@ghost
Copy link
Author

ghost commented Oct 21, 2019 via email

@KaBankz
Copy link
Owner

KaBankz commented Oct 21, 2019

I appreciate the effort, but I don't think it's safe to share your account with anyone besides yourself. You are free to fork this repo and work on it yourself. If you want to learn how to code this script, I recommend you google javascript tutorials and start learning from the basics.

@ghost
Copy link
Author

ghost commented Oct 21, 2019 via email

@ghost
Copy link
Author

ghost commented Oct 21, 2019 via email

@KaBankz
Copy link
Owner

KaBankz commented Oct 21, 2019

To change something on a website requires you to manipulate the DOM with javascript. If you go to youtube and watch some videos on DOM manipulation with javascript you should be set.

@ghost
Copy link
Author

ghost commented Oct 21, 2019 via email

@ghost
Copy link
Author

ghost commented Oct 22, 2019 via email

@KaBankz
Copy link
Owner

KaBankz commented Oct 22, 2019

Hacking pupilpath from the inside would be more difficult than necessary and illegal. Just bring your grades up instead of becoming a criminal. This userscript is for those times when you just want to flex better grades or just calculate an average.

@ghost
Copy link
Author

ghost commented Oct 22, 2019 via email

@KaBankz
Copy link
Owner

KaBankz commented Oct 22, 2019

Opps, my bad for the misinterpretation. But yeah that is possible, but I never tried it, for that I'd assume all you would have to do is change the element the grade is in to be a input. You can try that out and see what you like more.

@ghost
Copy link
Author

ghost commented Oct 22, 2019

ok, but i have a question. If you make an inspect elemnt change, how would you save it, so that everytime you open that certain website it runs automatically just like it would with tampermonkey.

@KaBankz
Copy link
Owner

KaBankz commented Oct 22, 2019

I don't think something like that is possible, I may be wrong, but google it just to make sure.

@ghost
Copy link
Author

ghost commented Oct 22, 2019 via email

@KaBankz
Copy link
Owner

KaBankz commented Oct 22, 2019

So for what you want all you would have to do is add a event listener to the element the grade is in, and make it open the grade changer popup. No need for inspect element.

@ghost
Copy link
Author

ghost commented Oct 22, 2019

Yeah but everytime i try to do that, it either gives me to many Ids, or says undefined. And By the way, I started a public gist. Its basically your code and me trying to add stuff to it.

@KaBankz
Copy link
Owner

KaBankz commented Oct 22, 2019

Yes you should get back a bunch of id's, each one represents a grade for each class. I recommend you use querySelectorAll to get all the elements with a grade in it, then loop over them with forEach, and add an event listener to each element to open the grade changer popup.

@ghost
Copy link
Author

ghost commented Oct 22, 2019

ok, i will see if i can do that and i will tell u

@ghost
Copy link
Author

ghost commented Oct 22, 2019

what if you cant find an id for something. For example it says : for a certain thing. It doesn't say 100, which is the etxt im trying to edit.

@KaBankz
Copy link
Owner

KaBankz commented Oct 22, 2019

If there is no class or ID, then you will have to select it from child nodes or parent nodes. You should learn more about the DOM, this entire userscript relies on modifying the DOM so you need to have an understanding on how to select elements, change elements, add/remove elements, and updating elements. If you have any questions google them, stackoverflow is a godsend and should have an answer to all your questions. When I made this userscript I had little to no understanding of javascript and stackoverflow was all I needed to make this userscript.

@ghost
Copy link
Author

ghost commented Oct 22, 2019

ok thank you,!

@ghost
Copy link
Author

ghost commented Jan 12, 2020 via email

@KaBankz
Copy link
Owner

KaBankz commented Jan 12, 2020

There is no "h" tag in HTML, so I assume you meant a header tag such as "h1". To edit what's between the tag you first have to select it by using querySelector, getElementById, or any other selector method. Then depending on what you want to change you can use innerText to change the text or innerHtml to change the HTML.

@ghost
Copy link
Author

ghost commented Jan 12, 2020 via email

@ghost
Copy link
Author

ghost commented Jan 12, 2020 via email

@ghost
Copy link
Author

ghost commented Jan 12, 2020 via email

@KaBankz
Copy link
Owner

KaBankz commented Jan 16, 2020

The issue with the code only working in the console is probably because you are trying to run code that modifies DOM elements that have not yet been rendered. It works in the console because the page has finished rendering when you run the code, but for userscripts you have to specify the run time or it will try to run code before the page has finished loading. Here is a reference to help you understand it better: https://www.tampermonkey.net/documentation.php#_run_at For your case you should use:

// @run-at    document-end

When you do this:

document.getElementsByTagName("p")[3].innerHTML="Class Status: <span id=standing style.color= #AA9901><img src=/img/ico/tick.png> 82.09 - Borderline</span>";

You are selecting all the p tags, then using an index (3 in this case) to select a single one. This is not what you should do. That will select all p tags even ones that do not contain grades. I recommend that you find an element that wraps all the grade elements. In my original code, I have this:

document.querySelectorAll("table#progress-card > tbody > tr > td > span");

This code selects only grades because I selected the span element that contained all the grades elements. With this, you can just loop through the grades like so :

const gradeParent = document.querySelectorAll('table#progress-card > tbody > tr > td > span');
gradeParent.forEach(e => {
  const originalGrade = parseFloat(e.innerText);
  const className = e.parentElement.parentElement.parentElement.childNodes[1].innerText.toUpperCase();
  console.log(`${className} = ${originalGrade}`);
  switch (className) {
    case 'ELA':
      e.innerHTML = `Class Status: <span id="standing" style="color:#AA9901";><img src="/img/ico/tick.png" /> 82.09 - Borderline</span>`;
      break;
    case 'MATH':
      e.innerHTML = `Class Status: <span id="standing" style="color:#AA9901";><img src="/img/ico/star.png" /> 90 - Passing</span>`;
      break;
  }
  // Whatever else you need...
});

But as you mentioned before PupilPath changed their website, so these selectors might not work, you will have to modify it to fit your use case. If you have trouble using selectors, then you should do some google searches, I personally learned how to use selectors by watching videos on youtube on web scraping.

@ghost
Copy link
Author

ghost commented Jan 17, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant