public IEnumerable <GeckoElement> GetElementsByJQuery(string jQuery) { JsVal jsValue; var elements = new List <GeckoElement>(); using (var autoContext = new AutoJSContext()) { autoContext.PushCompartmentScope((nsISupports)m_Window.Document.DomObject); jsValue = autoContext.EvaluateScript(jQuery); if (!jsValue.IsObject) { return(elements); } if (!SpiderMonkey.JS_HasProperty(autoContext.ContextPointer, jsValue.AsPtr, "length")) { return(null); } var length = SpiderMonkey.JS_GetProperty(autoContext.ContextPointer, jsValue.AsPtr, "length").ToInteger(); if (length == 0) { return(null); } for (var elementIndex = 0; elementIndex < length; elementIndex++) { var firstNativeDom = SpiderMonkey.JS_GetProperty(autoContext.ContextPointer, jsValue.AsPtr, elementIndex.ToString(CultureInfo.InvariantCulture)).ToComObject(autoContext.ContextPointer); var element = Xpcom.QueryInterface <nsIDOMHTMLElement>(firstNativeDom); if (element != null) { elements.Add(GeckoHtmlElement.Create(element)); } } } return(elements); }
public void UrlTest() { var service = Xpcom.GetService <nsIIOService>(Contracts.NetworkIOService); nsIURI ret; using (var str = new nsAUTF8String("http://www.google.com")) { ret = service.NewURI(str, null, null); } var ret2 = Xpcom.QueryInterface <nsIURL>(ret); var counter = Marshal.ReleaseComObject(ret); Assert.AreEqual(counter, 1); var serviceCounter = Marshal.ReleaseComObject(service); // Xpcom.GetService ref + 1 // IOService static contrustor ref + 1 #if false Assert.AreEqual(serviceCounter, 0); #endif }
public BrowerGecko() { InitializeComponent(); rqAdword = new AdwordRequest(); _googleAdwordService = new GoogleAdwordService(); excutePath = Path.GetDirectoryName(Application.ExecutablePath); Xpcom.Initialize(excutePath + @"\Gecko"); //Xpcom.Initialize(@"F:\Sample\Gecko33\xulrunner-sdk\bin"); nsIBrowserHistory historyMan = Xpcom.GetService <nsIBrowserHistory>(Gecko.Contracts.NavHistoryService); historyMan = Xpcom.QueryInterface <nsIBrowserHistory>(historyMan); historyMan.RemoveAllPages(); // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/imgICache nsICookieManager CookieMan; CookieMan = Xpcom.GetService <nsICookieManager>("@mozilla.org/cookiemanager;1"); CookieMan = Xpcom.QueryInterface <nsICookieManager>(CookieMan); CookieMan.RemoveAll(); IPPublic = getPublicIP(); WriteLog(IPPublic.ToString()); WriteLogIP("Activated"); }
private OutputStream(nsIOutputStream outputStream) { _outputStream = outputStream; _seekableStream = Xpcom.QueryInterface <nsISeekableStream>(outputStream); _seekable = _seekableStream != null; }
public static OutputStream Create(nsIOutputStream stream) { var seekable = Xpcom.QueryInterface <nsISeekableStream>(stream); return(new OutputStream(stream, seekable)); }
public TraceableChannel CastToTraceableChannel() { var channel = Xpcom.QueryInterface <nsITraceableChannel>(_httpChannel); return(channel == null ? null : new TraceableChannel(channel)); }
public UploadChannel CastToUploadChannel() { var channel = Xpcom.QueryInterface <nsIUploadChannel>(_httpChannel); return(channel.Wrap(x => new UploadChannel(x))); }
/// <summary> /// Reflection-like Mozilla API /// </summary> /// <returns></returns> public ClassInfo GetClassInfo() { var iface = Xpcom.QueryInterface <nsIClassInfo>(_instance); return(iface == null ? null : new ClassInfo(iface)); }
public UploadChannel CastToUploadChannel() { var channel = Xpcom.QueryInterface <nsIUploadChannel>(_httpChannel); return(channel == null ? null : new UploadChannel(channel)); }
internal InputStream(nsIInputStream inputStream) { _inputStream = inputStream; _seekableStream = Xpcom.QueryInterface <nsISeekableStream>(inputStream); _seekable = _seekableStream != null; }
/// <summary> /// 启动PDF打印 /// </summary> public void StartPdfPrint() { try { const double kMillimetersPerInch = 25.4; var mPrint = Xpcom.QueryInterface <nsIWebBrowserPrint>(this.mWebBrowser.Window.DomWindow); var printService = Xpcom.GetService <nsIPrintSettingsService>("@mozilla.org/gfx/printsettings-service;1"); var printSettings = printService.GetGlobalPrintSettingsAttribute(); //输出文件 printSettings.SetOutputFormatAttribute(nsIPrintSettingsConsts.kOutputFormatPDF); //文件格式:pdf printSettings.SetToFileNameAttribute(new nsAString(this.mHtmlPdfPath)); printSettings.SetPrintToFileAttribute(true); //静默打印 printSettings.SetPrintSilentAttribute(true); printSettings.SetShowPrintProgressAttribute(false); //页面大小单位 printSettings.SetPaperSizeUnitAttribute(nsIPrintSettingsConsts.kPaperSizeMillimeters); //单位:mm //页面高度 printSettings.SetPaperHeightAttribute(this.mCheerPrintArgs.pageHeight); //页面宽度 printSettings.SetPaperWidthAttribute(this.mCheerPrintArgs.pageWidth); //边距,单位:英寸,1英寸=25.4毫米 printSettings.SetUnwriteableMarginTopAttribute(0d); printSettings.SetUnwriteableMarginBottomAttribute(0d); printSettings.SetUnwriteableMarginLeftAttribute(0d); printSettings.SetUnwriteableMarginRightAttribute(0d); //边距,单位:英寸,1英寸=25.4毫米 printSettings.SetMarginTopAttribute(this.mCheerPrintArgs.marginTop / kMillimetersPerInch); printSettings.SetMarginBottomAttribute(this.mCheerPrintArgs.marginBottom / kMillimetersPerInch); printSettings.SetMarginLeftAttribute(this.mCheerPrintArgs.marginLeft / kMillimetersPerInch); printSettings.SetMarginRightAttribute(this.mCheerPrintArgs.marginRight / kMillimetersPerInch); printSettings.SetEdgeTopAttribute(0d); printSettings.SetEdgeBottomAttribute(0d); printSettings.SetEdgeLeftAttribute(0d); printSettings.SetEdgeRightAttribute(0d); //横竖,0竖向,1横向 if (this.mCheerPrintArgs.portraitOrientation == 1) { printSettings.SetOrientationAttribute(nsIPrintSettingsConsts.kPortraitOrientation); } else { printSettings.SetOrientationAttribute(nsIPrintSettingsConsts.kLandscapeOrientation); } //页眉 printSettings.SetHeaderStrCenterAttribute(new nsAString(string.Empty)); printSettings.SetHeaderStrLeftAttribute(new nsAString(string.Empty)); printSettings.SetHeaderStrRightAttribute(new nsAString(string.Empty)); //页脚 printSettings.SetFooterStrRightAttribute(new nsAString(string.Empty)); printSettings.SetFooterStrLeftAttribute(new nsAString(string.Empty)); printSettings.SetFooterStrCenterAttribute(new nsAString(string.Empty)); //打印背景颜色 printSettings.SetPrintBGColorsAttribute(true); //打印背景图 printSettings.SetPrintBGImagesAttribute(true); //网页缩放适应页面 printSettings.SetShrinkToFitAttribute(true); mPrint.Print(printSettings, this); Marshal.ReleaseComObject(mPrint); } catch (COMException ex) { //GeckoError var errorCode = string.Format("{0}", ex.ErrorCode); var errorMsg = CheerBrwError.getErrorMsg(errorCode); CheerLib.LogWriter.Log(ex.ToString()); CheerLib.LogWriter.Error("Making PDF File Xpcom Error:{0}", errorMsg); var statusText = "Making PDF File Xpcom Error:" + errorMsg; this.RaiseStatusChanged(100, statusText); this.RaiseStatusFinished(502); } catch (Exception ex) { CheerLib.LogWriter.Log(ex.ToString()); var statusText = "Making PDF File Error!"; this.RaiseStatusChanged(100, statusText); this.RaiseStatusFinished(503); } //下一步到打印回调函数 }
public GeckoElement CastToGeckoElement() { var domElement = Xpcom.QueryInterface <nsIDOMElement>(_target.Instance); return(Gecko.Interop.ExtensionMethods.Wrap(domElement, GeckoElement.CreateDomElementWrapper)); }
public UploadChannel CastToUploadChannel() { var channel = Xpcom.QueryInterface <nsIUploadChannel>(_httpChannel); return(Gecko.Interop.ExtensionMethods.Wrap(channel, x => new UploadChannel(x))); }
public ScriptableInputStream() { var stream = Xpcom.CreateInstance <nsIScriptableInputStream>(Contracts.ScriptableInputStream); _scriptableInputStream = Xpcom.QueryInterface <nsIScriptableInputStream>(stream); }
private void ViewLink() { if (numberURL <= lstAdwordConfigs.Count - 1) { if (lstAdwordConfigs != null && lstAdwordConfigs.Count > 0) { objAdwordConfig = lstAdwordConfigs[numberURL]; } string[] arrKeyWord = objAdwordConfig.KeyWord.Split(','); string[] arrclickLimit = objAdwordConfig.LinkQuantityClick.Split(','); if (arrclickLimit.Length > 0) { Random rdClickLimit = new Random(); clickLimit = rdClickLimit.Next(int.Parse(arrclickLimit[0]), int.Parse(arrclickLimit[1])); //MessageBox.Show("số lần click tối đa : " + clickLimit.ToString()); } if (arrKeyWord.Length > 0) { int i = 0; //rdKeyWord.Next(0,arrKeyWord.Count()-1] Random rdKeyWord = new Random(); string strQuery = HttpUtility.UrlEncode(arrKeyWord[i]); // geckoBrower.Dispose(); geckoBrower.Navigate(googleURL + strQuery); } } else { clickLinkTimer.Stop(); clickLinkTimer.Enabled = false; clickLinkTimer.Dispose(); //MessageBox.Show("Done Number URL : " + numberURL); WriteLogIP("NewIP"); //click adsen //clickAdsenTimer = new Timer(); //clickAdsenTimer.Interval = (1 * 20 * 1000); //clickAdsenTimer.Tick += new EventHandler(clickAdsenTimer_Tick); //clickAdsenTimer.Start(); ////Loop khi reset IP System.Threading.Thread.Sleep(3 * 60000); IPPublic = getPublicIP(); WriteLog(IPPublic.ToString()); if (!IPPublic.Equals(IPPublic.ToString())) { MessageBox.Show(IPPublic); } numberURL = 0; nsIBrowserHistory historyMan = Xpcom.GetService <nsIBrowserHistory>(Gecko.Contracts.NavHistoryService); historyMan = Xpcom.QueryInterface <nsIBrowserHistory>(historyMan); historyMan.RemoveAllPages(); //clear cache nsICookieManager CookieMan; CookieMan = Xpcom.GetService <nsICookieManager>("@mozilla.org/cookiemanager;1"); CookieMan = Xpcom.QueryInterface <nsICookieManager>(CookieMan); CookieMan.RemoveAll(); loop_ViewLinkWithIP(); } }
internal static Certificate Create(nsIX509Cert2 certificate) { var cert3 = Xpcom.QueryInterface <nsIX509Cert3>(certificate); return(new Certificate(certificate, certificate, cert3)); }
private void StartMakingPdf() { nsIWebBrowserPrint print = Xpcom.QueryInterface <nsIWebBrowserPrint>(_browser.Window.DomWindow); var service = Xpcom.GetService <nsIPrintSettingsService>("@mozilla.org/gfx/printsettings-service;1"); var printSettings = service.GetNewPrintSettingsAttribute(); printSettings.SetToFileNameAttribute(_pathToTempPdf); printSettings.SetPrintToFileAttribute(true); printSettings.SetPrintSilentAttribute(true); //don't show a printer settings dialog printSettings.SetShowPrintProgressAttribute(false); if (_conversionOrder.PageHeightInMillimeters > 0) { printSettings.SetPaperHeightAttribute(_conversionOrder.PageHeightInMillimeters); printSettings.SetPaperWidthAttribute(_conversionOrder.PageWidthInMillimeters); printSettings.SetPaperSizeUnitAttribute(1); //0=in, >0 = mm } else { //doesn't actually work. Probably a problem in the geckofx wrapper. Meanwhile we just look it up from our small list //printSettings.SetPaperNameAttribute(_conversionOrder.PageSizeName); var size = GetPaperSize(_conversionOrder.PageSizeName); const double inchesPerMillimeter = 0.0393701; // (or more precisely, 0.0393700787402) printSettings.SetPaperHeightAttribute(size.HeightInMillimeters * inchesPerMillimeter); printSettings.SetPaperWidthAttribute(size.WidthInMillimeters * inchesPerMillimeter); } // BL-2346: On Linux the margins were not being set correctly due to the "unwritable margins" // which were defaulting to 0.25 inches. printSettings.SetUnwriteableMarginTopAttribute(0d); printSettings.SetUnwriteableMarginBottomAttribute(0d); printSettings.SetUnwriteableMarginLeftAttribute(0d); printSettings.SetUnwriteableMarginRightAttribute(0d); //this seems to be in inches, and doesn't have a unit-setter (unlike the paper size ones) const double kMillimetersPerInch = 25.4; // (or more precisely, 25.3999999999726) printSettings.SetMarginTopAttribute(_conversionOrder.TopMarginInMillimeters / kMillimetersPerInch); printSettings.SetMarginBottomAttribute(_conversionOrder.BottomMarginInMillimeters / kMillimetersPerInch); printSettings.SetMarginLeftAttribute(_conversionOrder.LeftMarginInMillimeters / kMillimetersPerInch); printSettings.SetMarginRightAttribute(_conversionOrder.RightMarginInMillimeters / kMillimetersPerInch); printSettings.SetOrientationAttribute(_conversionOrder.Landscape ? 1 : 0); printSettings.SetHeaderStrCenterAttribute(""); printSettings.SetHeaderStrLeftAttribute(""); printSettings.SetHeaderStrRightAttribute(""); printSettings.SetFooterStrRightAttribute(""); printSettings.SetFooterStrLeftAttribute(""); printSettings.SetFooterStrCenterAttribute(""); printSettings.SetPrintBGColorsAttribute(true); printSettings.SetPrintBGImagesAttribute(true); printSettings.SetShrinkToFitAttribute(false); //TODO: doesn't seem to do anything. Probably a problem in the geckofx wrapper //printSettings.SetScalingAttribute(_conversionOrder.Zoom); printSettings.SetOutputFormatAttribute(2); // 2 == kOutputFormatPDF Status = "Making PDF.."; print.Print(printSettings, this); _checkForPdfFinishedTimer.Enabled = true; }
public void Ana_Islem() { if (prxy_lstesi.Count != 0) { geri_sayim2 = geri_sayim; timer2.Stop(); timer2.Enabled = false; timer3.Stop(); timer3.Enabled = false; Xpcom.QueryInterface <nsICookieManager>(Xpcom.GetService <nsICookieManager>("@mozilla.org/cookiemanager;1")).RemoveAll(); CookieManager.RemoveAll(); ayrac = Rastgele_prxy.Split(':'); GeckoPreferences.User["general.useragent.override"] = Rastgele_user_agents; switch (tur) { case "4": GeckoPreferences.Default["network.proxy.socks"] = ayrac[0]; GeckoPreferences.Default["network.proxy.socks_port"] = Convert.ToInt32(ayrac[1]); GeckoPreferences.User["network.proxy.socks_version"] = 4; break; case "5": GeckoPreferences.Default["network.proxy.socks"] = ayrac[0]; GeckoPreferences.Default["network.proxy.socks_port"] = Convert.ToInt32(ayrac[1]); GeckoPreferences.User["network.proxy.socks_version"] = 5; break; case "h": GeckoPreferences.Default["network.proxy.type"] = 1; GeckoPreferences.Default["network.proxy.http"] = ayrac[0]; GeckoPreferences.Default["network.proxy.http_port"] = Convert.ToInt32(ayrac[1]); break; case "s": GeckoPreferences.Default["network.proxy.http"] = ayrac[0]; GeckoPreferences.Default["network.proxy.http_port"] = Convert.ToInt32(ayrac[1]); GeckoPreferences.Default["network.proxy.ssl"] = ayrac[0]; GeckoPreferences.Default["network.proxy.ssl_port"] = Convert.ToInt32(ayrac[1]); break; } geckoWebBrowser1.Navigate(Rastgele_url, GeckoLoadFlags.BypassHistory, Rastgele_referer, null, null); ((Form1)(Application.OpenForms["Form1"])).listBox3.Items.Add(Rastgele_url + " Adresine yönlendirildi. " + Rastgele_prxy); Rastgele_url = URL_Listesi[new Random().Next(0, URL_Listesi.Count - 1)]; Rastgele_prxy = prxy_lstesi[new Random().Next(0, prxy_lstesi.Count - 1)]; prxy_lstesi.Remove(Rastgele_prxy); Rastgele_referer = referer_listesi[new Random().Next(0, referer_listesi.Count - 1)]; Rastgele_user_agents = user_Agent_listesi[new Random().Next(0, user_Agent_listesi.Count - 1)]; if (kullanilanlar.Contains(Rastgele_url)) { Rastgele_url = URL_Listesi[new Random().Next(0, URL_Listesi.Count - 1)]; kullanilanlar.Add(Rastgele_url); } else { kullanilanlar.Add(Rastgele_url); } if (kullanilanlar.Contains(Rastgele_referer)) { Rastgele_referer = referer_listesi[new Random().Next(0, referer_listesi.Count - 1)]; kullanilanlar.Add(Rastgele_url); } else { kullanilanlar.Add(Rastgele_referer); } if (kullanilanlar.Contains(Rastgele_user_agents)) { Rastgele_user_agents = user_Agent_listesi[new Random().Next(0, user_Agent_listesi.Count - 1)]; kullanilanlar.Add(Rastgele_url); } else { kullanilanlar.Add(Rastgele_user_agents); } timer2.Enabled = true; timer2.Start(); timer3.Enabled = true; timer3.Start(); } else { ((Form1)(Application.OpenForms["Form1"])).listBox3.Items.Add(id + " Numaralı tarayıcının proxy listesi bitti."); Close(); } }
public GeckoElement CastToGeckoElement() { var domElement = Xpcom.QueryInterface <nsIDOMElement>(_target.Instance); return(domElement.Wrap(GeckoElement.CreateDomElementWrapper)); }
public nsIDocShell GetDocShellAttribute() { return(Xpcom.QueryInterface <nsIDocShell>(this.WebBrowser)); }