Dadafacer

Enjoy the pleasures of chaotic browsing

  1. // ==UserScript==
  2. // @name Dadafacer
  3. // @namespace 414c45.net
  4. // @description Enjoy the pleasures of chaotic browsing
  5. // @include *
  6. // @version 1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. /*
  11. Dadafacer
  12. Copyright (c) 2014 Ale
  13. This library is free software; you can redistribute it and/or
  14. modify it under the terms of the GNU Lesser General Public
  15. License as published by the Free Software Foundation, version 2.1.
  16. This library is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. Lesser General Public License for more details.
  20. You should have received a copy of the GNU Lesser General
  21. Public License along with this library; if not, write to the
  22. Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  23. Boston, MA 02111-1307 USA
  24. */
  25.  
  26. var html = document.getElementsByTagName('html')[0],
  27. doc = document.documentElement,
  28. body = html.getElementsByTagName('body')[0],
  29. elements = document.getElementsByTagName('div'),
  30. n = elements.length;
  31.  
  32. //Setting up angle variations for each DOM element
  33. var angles = new Array(n);
  34. for(var i = 0; i < n; i++) angles[i] = Math.random() - .5;
  35.  
  36. //Dealing with crossbrowsing issues
  37. var vendors = [
  38. 'transform',
  39. 'OTransform',
  40. 'msTransform',
  41. 'MozTransform',
  42. 'WebkitTransform'
  43. ];
  44.  
  45. /**
  46. * Define functions
  47. */
  48.  
  49. //Explode everything with care
  50. function destroy()
  51. {
  52. for(var i = 0; i < n; i++)
  53. {
  54. if(elements[i].tagName== 'body' || elements[i].tagName== 'ubershit') continue;
  55. //JQuery's crossbrowsing way of retrieving window's scroll top
  56. var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
  57. var a = Math.floor(angles[i] * top);
  58. for (var v = 0; v < vendors.length; v++)
  59. elements[i].style[ vendors[v] ] = 'rotate('+a+'deg)';
  60. }
  61. }
  62.  
  63. //Redirect after text selection using 'I'm feeling ducky' option of DuckDuckGo
  64. function redirect()
  65. {
  66. var txt = window.getSelection().toString();
  67. if(txt) window.location.href = "http://duckduckgo.com/?q=" + txt + " !";
  68. }
  69.  
  70. //Search a random element in current view
  71. function search()
  72. {
  73. var index = Math.floor( Math.random() * n );
  74. var rect = elements[index].getBoundingClientRect();
  75. window.scrollTo(rect.left, rect.top);
  76. }
  77.  
  78. /**
  79. * Add new elements to DOM
  80. */
  81.  
  82. //Title
  83. var title = document.createElement('ubershit');
  84. title.innerHTML = 'Dadafacer';
  85. title.setAttribute('style', 'background: #111; position: fixed; top: 20px; left: 20px; padding: 10px; color: yellow; font-family: monospace; letter-spacing: 2px; font-size: 10px; font-weight: bold; z-index: 101010;');
  86. body.appendChild(title);
  87. //Search button
  88. var button = document.createElement('ubershit');
  89. button.innerHTML = 'Enjoy chaos. Scroll to destroy. Click here to move. Select text to go.';
  90. button.setAttribute('id', 'button');
  91. button.setAttribute('style', 'background: yellow; position: fixed; top: 50px; left: 20px; padding: 10px; color: #111; font-family: monospace; letter-spacing: 2px; font-size: 10px; z-index: 101010;');
  92. body.appendChild(button);
  93.  
  94.  
  95. /**
  96. * Customize style
  97. */
  98.  
  99. //Cursor
  100. html.style.cursor = 'crosshair';
  101.  
  102.  
  103. /**
  104. * Bind events
  105. */
  106.  
  107. window.addEventListener('scroll', destroy, true);
  108. body.addEventListener('mouseup', redirect, true);
  109. button.addEventListener('click', search, true);
  110.  
  111.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址