PK ¹…¹, refspoof/PK Ó…¹,refspoof/content/PK ˆ¹,¾e¦I$$refspoof/content/contents.rdf chrome://refspoof/content/refspoof_overlay.xul PK °†¹,Û³ñ?&?&$refspoof/content/refspoof_overlay.js /* **** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is refspoof for Mozilla. * * The Initial Developer of the Original Code is Boyd Ebsworthy. * Portions created by the Initial Developer are Copyright (C) 2001 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ /** * spoof() * called by spoof button in overlay */ function spoof() { // test url : http://erotic.redclouds.com/dirtynina/members var URI = document.getElementById('urlbar').value; //from navigator.xul var toTab = document.getElementById('open_in_tab').checked; /* greets to xxxhq.com */ spoof_open(URI, getReferer(), toTab); } /** ref=url checkbox action handler **/ function ref_is_url_click() { document.getElementById('ref_is_url').checked; if(document.getElementById('ref_is_url').checked) { //was unchecked document.getElementById('referer-text').setAttribute("disabled", "true"); } else { //will checked document.getElementById('referer-text').removeAttribute("disabled"); } } /** * bookmark functions **/ var _init = 0; var gRDF = null; var gRDFC = null; var gRDFU = null; var gsource = null; var spoof_rdf = "file:///c:/spoof.rdf"; function getReferer() { var refisurl = document.getElementById('ref_is_url').checked; if(refisurl){ return document.getElementById('urlbar').value; } else { return document.getElementById('referer-text').value; } } function spoofmark_bt_click(){ var URI = document.getElementById('urlbar').value; if(!URI) return; add_spoofmark(URI, getReferer()); } function spoof_list_command(menuItem) { var URI = menuItem.getAttribute("label"); var referer = menuItem.getAttribute("referer"); spoof_open(URI , referer, document.getElementById('open_in_tab').checked); } /* special greets to a special site removes '!' from a URL */ function stripBang(URI) { var fixedURI; var index = URI.indexOf("!"); while(index > 0) { fixedURI = URI.substring(0,index); URI = fixedURI + URI.substring(index+1,URI.length); index = URI.indexOf("!"); } return URI; } /** add a spoofmark to the rdf file V2. stolen from sessionHistoryUI.js - WORKiNG for the first time at 25/05/2002 4:49AM w00t!! - wish i had doc... - note to self, moz fails/refuse to write in RDF file located in the chrome directory. . for now the file is c:/spoof.rdf */ function add_spoofmark(newURI, newReferer) { if(!newURI) return; /* clean up the ! */ newURI = stripBang(newURI); newReferer = stripBang(newReferer); if (!gRDF) { gRDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); } if (!gsource){ //gsource = gRDF.GetDataSource("chrome://refspoof/content/spoof.rdf"); gsource = gRDF.GetDataSource(spoof_rdf); if (!gsource) { alert("\n >>Can't get -> " + spoof_rdf + "<-\n"); return; } } if (gsource) { if (!gRDFC) { gRDFC = Components.classes["@mozilla.org/rdf/container-utils;1"].getService(Components.interfaces.nsIRDFContainerUtils); } try { var entries = gRDFC.MakeSeq(gsource, gRDF.GetResource("SP:spoof")); if (!entries) { alert("!entry : unable to make a sequence of spoofmark"); return; } //create a new node var newnode = gRDF.GetAnonymousResource(); //get a random id.. //store URL var fieldprop = gRDF.GetResource("http://www.spoof.com/SP-rdf#URL"); var newvalue = gRDF.GetLiteral(newURI); gsource.Assert(newnode, fieldprop, newvalue, true); //store referer var fieldprop = gRDF.GetResource("http://www.spoof.com/SP-rdf#Referer"); var newvalue = gRDF.GetLiteral(newReferer); gsource.Assert(newnode, fieldprop, newvalue, true); // Insert it to the beginning of the list. entries.InsertElementAt(newnode, 1, true); // try to flush datasource... gsource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush(); } catch(e) { alert("add_spoofmark got an E : " + e); } } } /** * spoof_open() * URI = destination url * refURI = referer url * toTab = true : open destination in a new tab. false : use current browser. */ function spoof_open(URI , refURI, toTab){ if(!URI) return; if(!refURI) { alert("Invalid referer"); return; } /* clean up the ! */ URI = stripBang(URI); refURI = stripBang(refURI); var browser = getBrowser(); var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); try { var refnsiURI = ioService.newURI(refURI, null, null); } catch(e) { // it isn't a valid url alert("caught an exception while converting the uri \n\"" + e + "\""); return; } /** the loadURI* functions take a string for the destination * and an [xpconnect wrapped nsIURi] for the referer */ if(toTab) { var tab = browser.addTab(URI, refnsiURI); if (!prefRoot.getBoolPref("browser.tabs.loadInBackground")) browser.selectedTab = tab; } else { browser.loadURI(URI, refnsiURI); } } /** bookmark * this is totally incomplete, see addBookmark.js for more information.. * also need to find a way to edit the bookmark property field... * see bm-props.js **/ /* function insertBookmarkAt(aURL, aTitle, aCharset, aFolderRes, aIndex) { const kBMSContractID = "@mozilla.org/browser/bookmarks-service;1"; const kBMSIID = Components.interfaces.nsIBookmarksService; const kBMS = Components.classes[kBMSContractID].getService(kBMSIID); kBMS.createBookmarkWithDetails(aTitle, aURL, aCharset, aFolderRes, aIndex); } */ /*** DATASOURCES experimentation ************************************************************* * not working code - attempt at using mozilla's bookmark instead of my own RDF. * i lack documentation on how to convert a xpconnect wrapped bookmark|uri can't remember * to something readable by a human... * Everything works but the CANT FIND A WAY section below... :( * var gRDF = null; var gRDFC = null; var gBookmarks = null; function spoof_emptyMenu(aParent) { var children = aParent.childNodes; for (var i = 0; i < children.length; i++ ) { var index = children[i].getAttribute( "index" ); if (index) aParent.removeChild( children[i] ); } } function spoof_createMenuItem( aParent, aIndex, aLabel) { var menuitem = document.createElement( "menuitem" ); menuitem.setAttribute( "label", aLabel ); menuitem.setAttribute( "index", aIndex ); aParent.appendChild( menuitem ); } var RDF_NS = "http://home.netscape.com/NC-rdf#"; function spoof_create_menu( aParent ) { var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); if (!gRDF) { gRDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); } if (!gBookmarks) { gBookmarks = gRDF.GetDataSource("rdf:bookmarks"); } if (gBookmarks) { if (!gRDFC) { gRDFC = Components.classes["@mozilla.org/rdf/container-utils;1"].getService(Components.interfaces.nsIRDFContainerUtils); } //var entries = gRDFC.MakeSeq(gLocalStore, gRDF.GetResource("nc:urlbar-history")).GetElements(); var entries = gRDFC.MakeSeq(gBookmarks, gRDF.GetResource("NC:BookmarksRoot")).GetElements(); // Delete any old menu items only if there are legitimate // urls to display, otherwise we want to display the // '(Nothing Available)' item. spoof_emptyMenu(aParent); if (!entries.hasMoreElements()) { //Create the "Nothing Available" Menu item and disable it. var na = gNavigatorBundle.getString("nothingAvailable"); createMenuItem(aParent, "nothing_available", na); aParent.firstChild.setAttribute("disabled", "true"); } var i = 0; while (entries.hasMoreElements()) { //alert("i = " + i); var entry = entries.getNext(); if (entry) { try { ******** CANT FIND A WAY * var type = gRDF.GetTarget(entry, gRDF.GetResource(RDF_NS + "type"), true); * type = type.QueryInterface(Components.interfaces.nsIRDFResource).Value; * if (!type || (type != (RDF_NS + "BookmarkSeparator") && type != (RDF_NS + "Bookmark") && type != (RDF_NS + "Folder"))) { * * } else { * * } ************************** } catch(ex) { // XXXbar not an nsIRDFLiteral for some reason. see 90337. alert(ex); continue; } var url = entry.Value; spoof_createMenuItem(aParent, i++, url); } } } } ***/PK †¹,›\ 4QQ%refspoof/content/refspoof_overlay.xul