Jump to content

[PSNP+ v8.3] Improved PSNP, game lists, and more...


HusKy

Recommended Posts

Hey everyone, thanks for all the positive feedback. I will be pushing first small feature update which will add ability to order your backlog and filter by platform - similar to how it works in your games list.

 

@DaivRules There are several guides available which you can use to get you up and running, for example this one. All in all, it requires some knowledge of JavaScript, HTML and CSS.

I have written my first browser script maybe 10 years ago and I write code for a living so PSNP+ only took me couple hours to make overall.

  • Like 2
Link to comment
Share on other sites

21 hours ago, Danny_Johansen said:

@HusKy

Psnp loads up the first 100 games so all the games after aren't loaded and they start loading when I open the backlog. If I first load the next batch of games in my profile it starts lower down the list and when I load them all, it won't load any.

 

This is true, even though personally I auto load all. :P I doubt it would make a difference to the script though, as it has to run after that.

 

Why is this script over 12 000 lines? And why is one of the lines over half a million in length? :S 

 

I won't be using this as I can't even really read what it does, and there's some strange stuff in it. The functionality it seems to provide doesn't seem all that complicated to create with some few simple classes and functions.

 

I'm also questing why this was hosted on drobox, and no auto updates (guess that's actually a good thing in this case). :S 

Edited by MMDE
Link to comment
Share on other sites

20 minutes ago, MMDE said:

 

Why is this script over 12 000 lines? And why is one of the lines over half a million in length? :S 

 

I won't be using this as I can't even really read what it does, and there's some strange stuff in it. The functionality it seems to provide doesn't seem all that complicated to create with some few simple classes and functions.

 

I'm also questing why this was hosted on drobox, and no auto updates (guess that's actually a good thing in this case). :S 

 

The script is less than 12k lines, most of it is just bundled jQuery (10.5k). I needed something to quickly create UI elements and for creating backlog items.

I will reduce the size in the next release and remove source maps (the long line you asked about). It's useful for getting error reports from users but I guess it can also cause confusion so I will just get rid of it.

 

Actually, my code is just a bunch of classes that run according to which page is loaded. The code itself is harmless, it doesn't make any HTTP requests.

The codebase is written in TypeScript and bundled with webpack if this technical info interests you.

 

It's hosted on Dropbox because it's free and auto updates do work.

The git repo I work in is hosted on GitHub and it's currently private.

Link to comment
Share on other sites

 

 

If this dude really want to continue making this stuff, he should make the code readable above all else.

 

Here's some tips:

  1. Use external libraries, don't put that shit into the script. For example, if you want jquery, you can just do this at the start of the file: 
    // @require      https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js

     

  2. The site markup changes from time to time, and you may want to add more updates, so be ready for it and use the 
    // @updateURL
    and 
    // @downloadURL
    parameters. Where updateURL shouldn't be to the same URL, but rather one with only the first part of the script, as it's just checking the version.
  3. I see you include the script to run on all pages, perhaps you should limit the scope a bit more. Here's some examples: 
    // @match        https://psnprofiles.com/100-club/*
    // @match        https://psnprofiles.com/trophies/*
    // @match        https://psnprofiles.com/trophy/*
    // @match        https://psnprofiles.com/*/log*
    // @match        https://psnprofiles.com/game-leaderboard/*
    // @match        https://psnprofiles.com/leaderboard*
    // @include      /^https://psnprofiles\.com/[^/]+$/
  4. If you want to add some more functionality, here's some more to fix:
    1. Direct link to someone's trophy list for that game when seeing them on a game leaderboard (not just to their profile).
    2. Fix sorting of trophy lists with missing timestamps.
    3. Fix the order of the trophy log, some of it goes missing from the pagination when you add enough "filter settings". Example, ugly as it may be:
      function logFix() {
        if (location.pathname.match(/\/.+?\/log.*/) !== null && location.pathname.match(/^\/trophies\//) === null) {
          var a, imgs = document.getElementsByClassName("game");
          for (var i = 0; i < imgs.length; i++) {
            a = imgs[i].parentElement;
            a.setAttribute("href", a.getAttribute("href") + "?order=date");
          }
          return true;
        }
      }

       

    4. Add an option to auto load all games, this is the code I use for this, which is mostly based on what Sly does. Don't mind how ugly it looks:
      function loadAllGames() {
        var gamesTable = $("#gamesTable > tbody"), page = 2, gp = location.search.substr(1);
        gp += (gp.length > 0 ? "&" : "") + "ajax=1&page=";
        function loadNextPage() {
          if ($("#load-more").length === 0) {
            addProfileButtons();
            return;
        }
        $("#load-more").remove();
        gamesTable.append("<tr id=\"table-loading\"><td colspan=\"6\"><div style=\"height: 100px;\"></div></td></tr>");
        var opts = {
          method: "GET",
          url: location.pathname,
          data: gp+page,
          holder: "#table-loading div",
          success: function(data) {
            $("#table-loading").remove();
            gamesTable.append(data.html);
            page = data.html.match(/nextPage = (\d+)/)[1];
            if (page === "0") {
              addProfileButtons();
              return;
            }
            loadNextPage();
          }
        };
        XHR(opts);
        }
        loadNextPage();
      }

       

36 minutes ago, HusKy said:

 

The script is less than 12k lines, most of it is just bundled jQuery (10.5k). I needed something to quickly create UI elements and for creating backlog items.

I will reduce the size in the next release and remove source maps (the long line you asked about). It's useful for getting error reports from users but I guess it can also cause confusion so I will just get rid of it.

 

Actually, my code is just a bunch of classes that run according to which page is loaded. The code itself is harmless, it doesn't make any HTTP requests.

The codebase is written in TypeScript and bundled with webpack if this technical info interests you.

 

It's hosted on Dropbox because it's free and auto updates do work.

The git repo I work in is hosted on GitHub and it's currently private.

 

Just require/include the jquery library as a link to google's hosting of it or something.

 

I got no idea what it does or if it makes any HTTP requests as it's unreadable to me.

 

And as far as I can see, the auto update stuff doesn't work, as you haven't added the correct parameters for this.

Edited by MMDE
should look better now
  • Like 3
Link to comment
Share on other sites

15 minutes ago, MMDE said:

 

Argue? Dude, I just gave you shit ton of help improving your code... I recommend nobody touch the script until you've made it readable.

 

 

You helped, though you came off a bit passive aggressive with your "readable" comment. 

 

@HusKy I'll be adding this as soon as I return home. 

  • Like 3
Link to comment
Share on other sites

6 minutes ago, MMDE said:

 

I guess you don't understand why that's a problem...

I thought it was taught in basic grade school by this point, but I mean some people like to install malicious programs and you can't change that, I know I'm going to comb through it before I install it lol

 

Good work and we'll appreciated @HusKy

Edited by mackenzie129
Link to comment
Share on other sites

1 minute ago, mackenzie129 said:

I thought it was taught in basic grade school by this point, but I mean some people like to install malicious programs and you can't change that, I know I'm going to comb through it before I install it lol

 

Yeah, and one of the issues is he has been adding a lot of well known libraries into the code, which there is support to add properly by just linking to a trusted source.

Just now, BlackJudas said:

I can appreciate the work you put into this, and thank you for propping up this community by investing your time and expertise in creating something everyone can benefit from.  Hopefully you don't regret doing this by taking the negative responses to heart.

 

If he works with this stuff, he should be used to code review IMO, so I don't know why he'd take it personal. And as he says, it only took him a couple of hours...

Link to comment
Share on other sites

15 minutes ago, MMDE said:

 

I guess you don't understand why that's a problem... When it's promoted on the site, it should be safe, which we don't know if it is when it's not readable. One can easily argue it should be removed, which I haven't asked for, I told him how to make it more readable.

 

I guess you still don't understand your language could be perceived as dickheaded. I'm going to remove myself from this public conversation, though if you'd like to continue this via PM, feel welcome to (please don't). 

  • Like 4
Link to comment
Share on other sites

4 minutes ago, MMDE said:

 

Which is why I haven't asked for it to be deleted... The worst part of your argument, which I disagree with you about is the part about the 12k lines of code. That's the problem. Obviously he didn't write it, but you don't know if he tempered with it, and you can hide shit in those lines. And there's absolutely no good reason to do it like that. Also, one of the lines is over a half million characters... it's about 900 000 characters in that file. Nobody is gonna read that.

I mean come on, do you really expect me to believe you only install open source software in your pc and meticulously check every line? Sometimes you trust your instincts, what's the most probable scenario here? The guy wanted to help the psnp community and as most coders do, left in some complicated non readable code, which could have been improved, but it worked so he left it there. Presumption of innocence, is all I'm saying

Link to comment
Share on other sites

4 minutes ago, panikooooos said:

I mean come on, do you really expect me to believe you only install open source software in your pc and meticulously check every line? Sometimes you trust your instincts, what's the most probable scenario here? The guy wanted to help the psnp community and as most coders do, left in some complicated non readable code, which could have been improved, but it worked so he left it there. Presumption of innocence, is all I'm saying

 

I install software from companies I trust too, and I usually want to know the bad sides of them like the business model etc. But as I told you, this can so easily be avoided. It's less work avoiding it than keeping it.

Edited by MMDE
  • Like 2
Link to comment
Share on other sites

2 minutes ago, Abysm_Nucleus said:

I haven't clicked a link that fast before. Thanks for all your effort. 

Oh by the way PSNP crew are working on useless implementations, right? LOL.

 

Crew? Useless implementations? Sly made this web site.

Edited by MMDE
  • Like 1
Link to comment
Share on other sites

Just now, HusKy said:

I really didn't think things would turn out this way, but I will provide some info about this script and it's internals.

Before I start, I will just say that if you don't trust this script, you don't need to use it and that's fine.

  1. The script is written in TypeScript and bundled with a tool (webpack) which allows it to run in a web browser.
  2. Actual source code without libraries is 1023 lines of code - includes typescript code, html and css.
  3. jQuery
    1. This library is part of the bundle and comes from https://www.npmjs.com/package/jquery which is an official distribution channel.
    2. For what it's worth, I'm planning to remove it as it's not suitable for what I need, but I will continue bundling all of the source code in.
    3. I won't be using remote URL for it for the time being.

 

Don't worry. I have used it already. You can milk bitcoin from my PC which has 1080Ti. No worries.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...