loadletter / mangaupdates-urlfix

Userscript that adds website and IRC links on the groups pages of mangaupdates.com
63 stars 10 forks source link

Mangaupdates.com updated, script doesnt work anymore #17

Closed byleco1234 closed 5 years ago

byleco1234 commented 5 years ago

There was a site update today (23rd of February) and script stopped working, cant see group websites anymore https://www.mangaupdates.com/news.html?id=119804

Geese1 commented 5 years ago

Same here. Neither this, nor the Cover Preview scripts are now working after the site redesign. Really loved both, and if there's any way to get them functioning again that would be great.

Vilacard commented 5 years ago

Nothing to add other than to say it also no longer works for me.

byleco1234 commented 5 years ago

Same here. Neither this, nor the Cover Preview scripts are now working after the site redesign. Really loved both, and if there's any way to get them functioning again that would be great.

Cover preview (at least the one i use) has been updated and it works now https://greasyfork.org/en/scripts/26513-mangaupdates-cover-preview

anon-programmer commented 5 years ago

I figured out the issue, it has to do with resolving IRC link. Fixing that will get the website link to work again, but with the changes to MU's UI, the "Site" portion will be placed at the bottom and I'm not familiar enough with JS to fix the UI.

edit (28-02-2019): Forgot to mention I tested this fix against Chromium with Tampermonkey. I'll check out the "fix" against FF and Greasemonkey/Violent monkey/Tampermonkey. If I have free time I'll look at this further when I have more free time to fix the UI side of things too.

function fix_irc() {
  var list = document.getElementsByClassName("text");
  var irc='';

  for (var i=0; i<list.length; i++){
      if(list[i].innerHTML == "<u>IRC</u>") {
          list[i].id = "fixed_irc_url";
          if((irc=list[i].nextElementSibling.innerText) != "<i>No IRC</i>") {
              var a = irc.replace(/^.+@/,'');
              var b = irc.replace('#','').replace(/@.*/,'');
              list[++i].innerHTML='<a href="irc://'+a+'/'+b+'"><u>'+a+'/'+b+'</u></a>';
          }
        break;
      }
  }
}
Vilacard commented 5 years ago

That seems to work for now. Thanks!

Geese1 commented 5 years ago

I figured out the issue, it has to do with resolving IRC link. Fixing that will get the website link to work again, but with the changes to MU's UI, the "Site" portion will be placed at the bottom and I'm not familiar enough with JS to fix the UI.

function fix_irc() {
  var list = document.getElementsByClassName("text");
  var irc='';

  for (var i=0; i<list.length; i++){
      if(list[i].innerHTML == "<u>IRC</u>") {
          list[i].id = "fixed_irc_url";
          if((irc=list[i].nextElementSibling.innerText) != "<i>No IRC</i>") {
              var a = irc.replace(/^.+@/,'');
              var b = irc.replace('#','').replace(/@.*/,'');
              list[++i].innerHTML='<a href="irc://'+a+'/'+b+'"><u>'+a+'/'+b+'</u></a>';
          }
        break;
      }
  }
}

Thanks for the update! Was easy enough to add it manually, and now it works like it should. It's not pretty (it looks weird when there's no IRC link to use!), but the functionality is there, and that's what matters.

Really appreciate you taking the time to work on this!

Hyacia commented 5 years ago

I figured out the issue, it has to do with resolving IRC link. Fixing that will get the website link to work again, but with the changes to MU's UI, the "Site" portion will be placed at the bottom and I'm not familiar enough with JS to fix the UI.

edit (28-02-2019): Forgot to mention I tested this fix against Chromium with Tampermonkey. I'll check out the "fix" against FF and Greasemonkey/Violent monkey/Tampermonkey. If I have free time I'll look at this further when I have more free time to fix the UI side of things too.

function fix_irc() {
  var list = document.getElementsByClassName("text");
  var irc='';

  for (var i=0; i<list.length; i++){
      if(list[i].innerHTML == "<u>IRC</u>") {
          list[i].id = "fixed_irc_url";
          if((irc=list[i].nextElementSibling.innerText) != "<i>No IRC</i>") {
              var a = irc.replace(/^.+@/,'');
              var b = irc.replace('#','').replace(/@.*/,'');
              list[++i].innerHTML='<a href="irc://'+a+'/'+b+'"><u>'+a+'/'+b+'</u></a>';
          }
        break;
      }
  }
}

Nice work. I fixed the formatting (using Greasemonkey on FireFox, so I can confirm your fix works on FF). I never used this script before, so I'm not sure exactly how you'd want it to behave, but the link fixing works. I put the site and site link elements somewhere that made sense to me (under IRC info).

Not exactly elegant, but I'm not overly familiar with JS. I had to split up the "Site" + suggestion box link and actual URL to preserve the (div tag...) "table" format on MU. I couldn't find a way around this due to the way the DOM works. The createElement function automatically appends the closing tag, but also prevents you from closing it within the innerHTML element as you might want to. The resulting div block messed up the table layout.

Relevant changes (last 7 lines in original):

    var urlfix_site_fixed = document.getElementById('fixed_group_suggestion');
    var urlfix_site = urlfix_site_fixed || document.createElement('div');
urlfix_site.setAttribute("class", "p-1 col-6 text");
    urlfix_site.id = "fixed_group_suggestion";
    urlfix_site.innerHTML = '<u>Site</u><a href="#" onclick="urlfix_openSuggBox();"> (Suggest an update)</a>';
    var urlfix_site_par = document.querySelector('div.general_table:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(5)');
    urlfix_site_par.parentNode.insertBefore(urlfix_site, urlfix_site_par);
    if(!urlfix_site_fixed) {
        var urlfix_irc_par = document.getElementById("fixed_irc_url").parentNode;
        urlfix_irc_par.parentNode.insertAfter(urlfix_site, urlfix_irc_par.nextSibling);
    }
    var site_link_fixed = document.getElementById('fixed_site_link');
    var site_link = site_link_fixed || document.createElement('div');
    site_link.setAttribute("class", "p-1 col-6 text");
    site_link.id = "fixed_site_link";
    site_link.innerHTML = (urlfix_groupSite === undefined ? '<i>No Info</i>' : ('<a target="_blank" alt="" href="' + urlfix_groupSite + '"><u>' + urlfix_groupSite + '</u></a>'));
    var site_link_par = document.querySelector('#fixed_group_suggestion');
    site_link_par.parentNode.insertBefore(site_link, urlfix_site);
    if(!site_link_fixed) {
        var site_link_par = document.getElementById("fixed_site_link");
        site_link_par.parentNode.insertBefore(site_link, urlfix_site_par.nextSibling);
    }

Full code: https://pastebin.com/qRKCaUyB

anon-programmer commented 5 years ago

Nice work. I fixed the formatting (using Greasemonkey on FireFox, so I can confirm your fix works on FF). I never used this script before, so I'm not sure exactly how you'd want it to behave, but the link fixing works. I put the site and site link elements somewhere that made sense to me (under IRC info). Relevant changes (last 7 lines in original):

Full code: https://pastebin.com/qRKCaUyB

Very nice! Thanks for working on the UI portion, I had so much difficulties getting that to append to the UI element of MU design it was so confusing to me. I checked it on chromium and it's working fine for me too.

Geese1 commented 5 years ago

Thanks for the UI fix, Hyacia! I use Tampermonkey in Chrome and it works fine there. The only issue I'm still seeing is that if there's no IRC channel, the script still pastes: "NoIRC/NoIRC" as a hyperlink. Ideally, it should just be regular wording that reads: "No IRC" in the same italicized font as when there's no Facebook or Twitter for example.

Other than that, great work! So glad the community is coming together to resolve this issue!

Hyacia commented 5 years ago

Thanks for the UI fix, Hyacia! I use Tampermonkey in Chrome and it works fine there. The only issue I'm still seeing is that if there's no IRC channel, the script still pastes: "NoIRC/NoIRC" as a hyperlink. Ideally, it should just be regular wording that reads: "No IRC" in the same italicized font as when there's no Facebook or Twitter for example.

Other than that, great work! So glad the community is coming together to resolve this issue!

That didn't bother me at the time, but it does now that you've mentioned it. The issue was literally just 4 letters (the last 4 in the element reference). Change innerText to innerHTML in line 54 and it works as you described.

if((irc=list[i].nextElementSibling.innerHTML) != "<i>No IRC</i>") {

@anon-programmer Might want to update to include this

anon-programmer commented 5 years ago

Thanks Geese1 andHyacia, I have changed that in the IRC link function.

Geese1 commented 5 years ago

That didn't bother me at the time, but it does now that you've mentioned it. The issue was literally just 4 letters (the last 4 in the element reference). Change innerText to innerHTML in line 54 and it works as you described.

if((irc=list[i].nextElementSibling.innerHTML) != "<i>No IRC</i>") {

@anon-programmer Might want to update to include this

Thanks, works like a charm!

loadletter commented 5 years ago

Sorry, I was busy, I will look into updating this

Anutrix commented 5 years ago

Did it work or not? If it does work, why is this issue still open. I'm lost.

Hyacia commented 5 years ago

Yes, the script works. This issue can be closed. Just a small cosmetic issue that remains to be fixed. See this comment. @loadletter @Anutrix

loadletter commented 5 years ago

@Hyacia It seems to work for me, try reinstalling the script

Hyacia commented 5 years ago

@loadletter It does appear to be working. I hadn't updated the script; I just looked at the code and thought it hadn't been changed. Seems like anon-programmer took a different approach and his code was merged. All good.