soup.io_force_working_asset_hosts

Right now soup.io have problem with many image hosts which results in nearly half of the images being not displayed. Here's a workaround - force browser to use known-to-be-working asset hosts.

当前为 2016-11-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name soup.io_force_working_asset_hosts
  3. // @namespace http://animeisouronlysalvationfromthehorrorofexistence.soup.io/
  4. // @include http://*soup.io/*
  5. // @include https://*soup.io/*
  6. // @description Right now soup.io have problem with many image hosts which results in nearly half of the images being not displayed. Here's a workaround - force browser to use known-to-be-working asset hosts.
  7. // @version 3
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12. // A list of known to be working asset hosts.
  13. var working_hosts = [ 'asset-0', 'asset-1', 'asset-2', 'asset-3', 'asset-4', 'asset-5' ];
  14.  
  15. function force_working_asset_hosts(){
  16. var tags = document.getElementsByTagName('img');
  17. var links = document.getElementsByTagName('a');
  18.  
  19.  
  20. for (var i = 0; i < tags.length; i++) {
  21. var rand_host = working_hosts[Math.floor(Math.random()*working_hosts.length)];
  22. tags[i].src = tags[i].src.replace(/asset-[^.]+/g, rand_host);
  23. }
  24.  
  25. for (var i = 0; i < links.length; i++) {
  26. var rand_host = working_hosts[Math.floor(Math.random()*working_hosts.length)];
  27. links[i].href = links[i].href.replace(/asset-[^.]+/g, rand_host);
  28. }
  29. }
  30.  
  31. force_working_asset_hosts();
  32.  
  33. var observer = new MutationObserver(function(mutations) {
  34. force_working_asset_hosts();
  35. });
  36.  
  37. var config = { attributes: true, childList: true, characterData: true };
  38. var target = document.getElementById('more_history');
  39. observer.observe(target, config);