Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var ipfuck = {
- inited: false,
- init: function() {
- if (!this.inited) {
- if (this.get_pref('ipfuck_enabled') == true)
- this.register();
- this.inited = true;
- }
- },
- observe: function(subject, topic, data) {
- if (topic == "http-on-modify-request") {
- var channel = subject.QueryInterface(Components.interfaces.nsIChannel);
- if (!this.in_array(channel.originalURI.asciiHost, this.get_pref('white_list').split(','))) {
- var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
- if (this.get_pref('synchronize')) {
- var ip2 = ip;
- var ip3 = ip;
- } else {
- var ip2 = this.get_ip();
- var ip3 = this.get_ip();
- }
- if (this.get_pref('xforwarded'))
- httpChannel.setRequestHeader("X-FORWARDED-FOR", ip, false);
- if (this.get_pref('via'))
- httpChannel.setRequestHeader("VIA", ip2, false);
- if (this.get_pref('clientip'))
- httpChannel.setRequestHeader("CLIENT-IP", ip3, false);
- }
- }
- },
- get observerService() {
- return Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
- },
- register: function() {
- this.set_pref('ipfuck_enabled', true);
- document.getElementById('ipfuck-toolbar-button').className = 'toolbarpanel-menu-iconic ipfuck_enabled';
- this.observerService.addObserver(this, "http-on-modify-request", false);
- },
- unregister: function() {
- this.set_pref('ipfuck_enabled', false);
- document.getElementById('ipfuck-toolbar-button').className = 'toolbarpanel-menu-iconic ipfuck_disabled';
- this.observerService.addObserver(this, "http-on-modify-request", false);
- },
- toggle_state:function() {
- this.register();
- 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')) + ".";
- 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')) + ".";
- 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')) + ".";
- 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'));
- },
- get_ip: function() {
- if (this.get_pref('mode') == 'list') {
- var ips = this.get_pref('ip_list').split(',');
- return ips[Math.round(Math.random() * (ips.length - 1))];
- } else {
- if (this.get_pref('ipfuck_enabled')) {
- 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')) + ".";
- 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')) + ".";
- 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')) + ".";
- 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'));
- qb = ip;
- return ip;
- } else {
- ip = qb;
- return ip;
- }
- }
- },
- in_array:function(needle, haystack) {
- for (var i = 0; i < haystack.length; i++) {
- if (haystack[i] == needle)
- return true;
- }
- return false;
- },
- get_pref: function(pref_name) {
- var prefs = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- prefs = prefs.getBranch("extensions.ipfuck.");
- var type = prefs.getPrefType(pref_name);
- if (type == 128)
- return prefs.getBoolPref(pref_name);
- else if (type == 32)
- return prefs.getCharPref(pref_name);
- else //type == 64
- return prefs.getIntPref(pref_name);
- },
- set_pref: function(pref_name, value) {
- var prefs = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- prefs = prefs.getBranch("extensions.ipfuck.");
- var type = prefs.getPrefType(pref_name);
- if (type == 128)
- return prefs.setBoolPref(pref_name, value);
- else if (type == 32)
- return prefs.setCharPref(pref_name, value);
- else //type == 64
- return prefs.setIntPref(pref_name, value);
- },
- addbutton: function() {
- var toolbar = document.getElementById("ipfuck-toolbar-button");
- var browserel = document.getElementById("nav-bar");
- if (browserel && !toolbar) {
- browserel.insertItem("ipfuck-toolbar-button");
- browserel.setAttribute("currentset", browserel.currentSet);
- document.persist("nav-bar", "currentset");
- }
- }
- };
- window.addEventListener("load", ipfuck.addbutton, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement