Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. var ipfuck = {
  2.  
  3. inited: false,
  4.  
  5. init: function() {
  6. if (!this.inited) {
  7. if (this.get_pref('ipfuck_enabled') == true)
  8. this.register();
  9.  
  10. this.inited = true;
  11. }
  12. },
  13.  
  14. observe: function(subject, topic, data) {
  15.  
  16. if (topic == "http-on-modify-request") {
  17.  
  18. var channel = subject.QueryInterface(Components.interfaces.nsIChannel);
  19.  
  20. if (!this.in_array(channel.originalURI.asciiHost, this.get_pref('white_list').split(','))) {
  21. var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
  22.  
  23.  
  24. if (this.get_pref('synchronize')) {
  25. var ip2 = ip;
  26. var ip3 = ip;
  27. } else {
  28. var ip2 = this.get_ip();
  29. var ip3 = this.get_ip();
  30. }
  31.  
  32. if (this.get_pref('xforwarded'))
  33. httpChannel.setRequestHeader("X-FORWARDED-FOR", ip, false);
  34.  
  35. if (this.get_pref('via'))
  36. httpChannel.setRequestHeader("VIA", ip2, false);
  37.  
  38. if (this.get_pref('clientip'))
  39. httpChannel.setRequestHeader("CLIENT-IP", ip3, false);
  40. }
  41. }
  42. },
  43.  
  44. get observerService() {
  45. return Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  46. },
  47.  
  48. register: function() {
  49. this.set_pref('ipfuck_enabled', true);
  50. document.getElementById('ipfuck-toolbar-button').className = 'toolbarpanel-menu-iconic ipfuck_enabled';
  51. this.observerService.addObserver(this, "http-on-modify-request", false);
  52. },
  53.  
  54. unregister: function() {
  55. this.set_pref('ipfuck_enabled', false);
  56. document.getElementById('ipfuck-toolbar-button').className = 'toolbarpanel-menu-iconic ipfuck_disabled';
  57. this.observerService.addObserver(this, "http-on-modify-request", false);
  58. },
  59.  
  60. toggle_state:function() {
  61. this.register();
  62. ip = parseInt(Math.round(Math.random() * parseInt(this.get_pref('ip_high_0') - this.get_pref('ip_low_0'))) + this.get_pref('ip_low_0')) + ".";
  63. ip += parseInt(Math.round(Math.random() * parseInt(this.get_pref('ip_high_1') - this.get_pref('ip_low_1'))) + this.get_pref('ip_low_1')) + ".";
  64. ip += parseInt(Math.round(Math.random() * parseInt(this.get_pref('ip_high_2') - this.get_pref('ip_low_2'))) + this.get_pref('ip_low_2')) + ".";
  65. ip += parseInt(Math.round(Math.random() * parseInt(this.get_pref('ip_high_3') - this.get_pref('ip_low_3'))) + this.get_pref('ip_low_3'));
  66. },
  67.  
  68. get_ip: function() {
  69.  
  70. if (this.get_pref('mode') == 'list') {
  71. var ips = this.get_pref('ip_list').split(',');
  72.  
  73. return ips[Math.round(Math.random() * (ips.length - 1))];
  74. } else {
  75. if (this.get_pref('ipfuck_enabled')) {
  76. var ip = parseInt(Math.round(Math.random() * parseInt(this.get_pref('ip_high_0') - this.get_pref('ip_low_0'))) + this.get_pref('ip_low_0')) + ".";
  77. ip += parseInt(Math.round(Math.random() * parseInt(this.get_pref('ip_high_1') - this.get_pref('ip_low_1'))) + this.get_pref('ip_low_1')) + ".";
  78. ip += parseInt(Math.round(Math.random() * parseInt(this.get_pref('ip_high_2') - this.get_pref('ip_low_2'))) + this.get_pref('ip_low_2')) + ".";
  79. ip += parseInt(Math.round(Math.random() * parseInt(this.get_pref('ip_high_3') - this.get_pref('ip_low_3'))) + this.get_pref('ip_low_3'));
  80. qb = ip;
  81. return ip;
  82. } else {
  83. ip = qb;
  84. return ip;
  85. }
  86. }
  87. },
  88.  
  89. in_array:function(needle, haystack) {
  90. for (var i = 0; i < haystack.length; i++) {
  91. if (haystack[i] == needle)
  92. return true;
  93. }
  94. return false;
  95. },
  96.  
  97. get_pref: function(pref_name) {
  98. var prefs = Components.classes["@mozilla.org/preferences-service;1"]
  99. .getService(Components.interfaces.nsIPrefService);
  100. prefs = prefs.getBranch("extensions.ipfuck.");
  101.  
  102. var type = prefs.getPrefType(pref_name);
  103.  
  104. if (type == 128)
  105. return prefs.getBoolPref(pref_name);
  106. else if (type == 32)
  107. return prefs.getCharPref(pref_name);
  108. else //type == 64
  109. return prefs.getIntPref(pref_name);
  110. },
  111.  
  112. set_pref: function(pref_name, value) {
  113. var prefs = Components.classes["@mozilla.org/preferences-service;1"]
  114. .getService(Components.interfaces.nsIPrefService);
  115. prefs = prefs.getBranch("extensions.ipfuck.");
  116.  
  117. var type = prefs.getPrefType(pref_name);
  118.  
  119. if (type == 128)
  120. return prefs.setBoolPref(pref_name, value);
  121. else if (type == 32)
  122. return prefs.setCharPref(pref_name, value);
  123. else //type == 64
  124. return prefs.setIntPref(pref_name, value);
  125. },
  126.  
  127. addbutton: function() {
  128. var toolbar = document.getElementById("ipfuck-toolbar-button");
  129. var browserel = document.getElementById("nav-bar");
  130. if (browserel && !toolbar) {
  131. browserel.insertItem("ipfuck-toolbar-button");
  132. browserel.setAttribute("currentset", browserel.currentSet);
  133. document.persist("nav-bar", "currentset");
  134. }
  135. }
  136. };
  137.  
  138. window.addEventListener("load", ipfuck.addbutton, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement