Entrance Chat Gallery Guilds Search Everyone Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining the forum??
February 12, 2026 - @23.39 (what is this?)
Activity rating: Four Stars Posts & Arts: 59/1k.beats Unread Topics | Unread Replies | My Stuff | Random Topic | Recent Posts Start New Topic  Submit Art
News: :wizard: You can make anything on the web! :wizard: Guild Events: There are no events!

+  MelonLand Forum
|-+  World Wild Web
| |-+  ☮︎ ∙ Communities & Webrings
| | |-+  A fix for random site for onionrings!


« previous next »
Pages: [1] Print
Author Topic: A fix for random site for onionrings!  (Read 27 times)
jack_dawlia
Casual Poster ⚓︎
*
View Profile WWW


catgirl irl
⛺︎ My Room

Artifacts:
Suck At Something September - Did It!GLaDOS' Test Chamber VeteranJoined 2024!
« on: February 10, 2026 @897.86 »

I recently realised an issue with my webrings (made using garlic.garden's amazing onionring :]), when i clicked the random button on the sites with my webring it would sometimes work and sometimes link to completely random places ',:'

After some digging i found the issue and a simple solution :)!

The issue lies in the widget code in the randomText variable: onclick='randomSite()'

I believe when a site has many onionrings or other scripts with a function named randomSite(), it will do likely that randomSite() rather than your webrings, so it will link to other sites that arent part of it! (thats why it works fine on the index page, there no other randoms :P)

So how do you fix it?

Simply naming your randomSite() to something unique to your webring should do the trick! e.g. i have randomApertureSite() for my aperture webring ^_^

Original code:
Code
...
function randomSite() {
  otherSites = sites.slice(); //create a copy of the sites list
  otherSites.splice(thisIndex, 1); //remove the current site so we don't just land on it again
  randomIndex = Math.floor(Math.random() * otherSites.length);
  location.href = otherSites[randomIndex];
}

...
  if (useRandom) {
    randomText = `<a href='javascript:void(0)' onclick='randomSite()'>random</a> | `;
  }
...

Fixed code:
Code
...
function randomYourWebringSite() {
  otherSites = sites.slice(); //create a copy of the sites list
  otherSites.splice(thisIndex, 1); //remove the current site so we don't just land on it again
  randomIndex = Math.floor(Math.random() * otherSites.length);
  location.href = otherSites[randomIndex];
}

...
  if (useRandom) {
    randomText = `<a href='javascript:void(0)' onclick='randomYourWebringSite()'>random</a> | `;
  }
...

Hope this can help someone else out :D!
Logged

- the silly (xe/xir)
Pages: [1] Print 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | ~ Send Feedback ~ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi