Instructables All Steps

Redirects to view all steps on Instructables projects.

  1. // ==UserScript==
  2. // @name Instructables All Steps
  3. // @namespace instructablesallsteps
  4. // @description Redirects to view all steps on Instructables projects.
  5. // @include http://*.instructables.com/id/*
  6. // @include https://*.instructables.com/id/*
  7. // @version 0.1
  8. // @grant none
  9. // ==/UserScript==
  10. (function () {
  11. var currentLocation = window.location;
  12. if (!containsQueryParameter(currentLocation, 'ALLSTEPS')) {
  13. newLocation = addQueryParameter(currentLocation, 'ALLSTEPS', null);
  14. currentLocation.replace(newLocation);
  15. }
  16. function containsQueryParameter(location, key) {
  17. return containsCaseInsensitive(location.search, key);
  18. }
  19. function addQueryParameter(location, key, value) {
  20. var separator = '';
  21. if (!containsQueryStringSeparator(location)) {
  22. separator = '?';
  23. } else if (containsQueryParameters(location)) {
  24. separator = '&';
  25. }
  26. return location.href + separator + key + '=' + value;
  27. }
  28. function containsQueryStringSeparator(location) {
  29. return contains(location.href, '?');
  30. }
  31. function containsQueryParameters(location) {
  32. return location.search != '';
  33. }
  34. function contains(value, substring) {
  35. return value.indexOf(substring) != - 1;
  36. }
  37. function containsCaseInsensitive(value, substring) {
  38. return value.search(new RegExp(substring, 'i')) != - 1;
  39. }
  40. }) ();