This feels like a stupid question, but there’s plenty of techniques out there that more expert coders use that I don’t know about. How do you preserve minor or major changes you may have made to a script made by someone else while still being able to update any new changes they have? Besides the obvious way of saving your changes somewhere and reinserting them.

  • curiosityLynx@kglitch.social
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    For CSS, this is pretty easy:
    Leave the original source alone, and make your modifications (and only the modifications) in a separate file that is loaded after the original source.

    Example
    Say the original source style has something like this:

    a:hover {
        color:green;
        text-decoration:underline;
    }
    
    

    and you want to remove that underline.
    Just put the following in your modifications file:

    a:hover {
        text-decoration:none;
    }
    
    

    Links will continue to become green when you hover over them, but they will no longer get underlined when you hover over them.

    If you can’t guarantee that your modifications will get loaded after the original, add !important like this:

    a:hover {
        text-decoration:none !important;
    }
    
    
    • Rhaedas@kbin.socialOP
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Good point for CSS changes since they can override the previous (usually). Some of my changes are in the JS functions though. I may just stick to the “hard” way, after all we may see some of this get wrapped into the base code eventually.

  • kglitch@kglitch.social
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    The software for this is called ‘git’. The general term for this family of software is “source control”. There are many types of source control but git is massively popular.

    All the changes are recorded in a “repository”. At any time you can add your own changes to your repository or import changes others made to theirs. Git takes care of merging the changed files together and warning you of anything it couldn’t merge because of conflicts. It’s pretty magical.

    Git was originally written by Linus, the guy who made the Linux kernel.

    That should give you plenty to google!

    For little snippets of CSS like user styles, git is probably overkill…?

    • Rhaedas@kbin.socialOP
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Yeah, I have an account for access and have looked at git stuff before and understand the general idea, but it’s still advanced for my ancient programming experience. What I’ll probably do is just use something like Notepad++ and its compare addon to look at the new vs. what I have and see if it’s just easier to patch manually rather than redo my additions. That’s how I’ve done code in the past, and it’s not like these are huge files.

  • Ori@sacredori.net
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    I’d be happy for someone to correct me if I’m wrong, but I feel as though you’re pretty much right with your last statement. Generally a project becomes forked and when the source is updated, you integrate the new changes into your now separate fork.

    • Rhaedas@kbin.socialOP
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      I was working on trying to figure out how to do a fork and add my changes to your fed awareness code, and there you go adding another option that I end up liking more than mine or the previous ones. So never mind. :)

      I did end up doubling the dot size for more visibility, but I think it works better than the rest because it’s marking where the actual federation input came from, the user name.