25 changed files with 734 additions and 64 deletions
@ -0,0 +1,12 @@ |
|||||
|
<UserControl x:Class="齐越慧眼.UserControls.BrowerControl" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
|
xmlns:local="clr-namespace:齐越慧眼.UserControls" |
||||
|
mc:Ignorable="d" |
||||
|
d:DesignHeight="450" d:DesignWidth="800"> |
||||
|
<Grid x:Name="grid"> |
||||
|
|
||||
|
</Grid> |
||||
|
</UserControl> |
@ -0,0 +1,205 @@ |
|||||
|
using CefSharp; |
||||
|
using CefSharp.Wpf; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows.Data; |
||||
|
using System.Windows.Documents; |
||||
|
using System.Windows.Input; |
||||
|
using System.Windows.Media; |
||||
|
using System.Windows.Media.Imaging; |
||||
|
using System.Windows.Navigation; |
||||
|
using System.Windows.Shapes; |
||||
|
|
||||
|
namespace 齐越慧眼.UserControls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// BrowerControl.xaml 的交互逻辑
|
||||
|
/// </summary>
|
||||
|
public partial class BrowerControl : UserControl |
||||
|
{ |
||||
|
ChromiumWebBrowser web; |
||||
|
public BrowerControl() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
|
||||
|
web = new ChromiumWebBrowser("https://www.taobao.com") |
||||
|
{ |
||||
|
BrowserSettings = |
||||
|
{ |
||||
|
DefaultEncoding = "UTF-8", |
||||
|
Plugins= CefState.Enabled, |
||||
|
//关于跨域限制
|
||||
|
WebSecurity = CefState.Disabled, |
||||
|
ApplicationCache=CefState.Enabled, |
||||
|
LocalStorage= CefState.Enabled |
||||
|
|
||||
|
}, |
||||
|
}; |
||||
|
|
||||
|
grid.Children.Add(web); |
||||
|
Loaded += BrowerControl_Loaded; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
private void BrowerControl_Loaded(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
web.WebBrowser.LoadingStateChanged += WebBrowser_LoadingStateChanged; |
||||
|
} |
||||
|
|
||||
|
private string lastUrl = string.Empty; |
||||
|
|
||||
|
private void WebBrowser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) |
||||
|
{ |
||||
|
if (lastUrl != e.Browser.MainFrame.Url) |
||||
|
{ |
||||
|
lastUrl = e.Browser.MainFrame.Url; |
||||
|
//开始单页查询
|
||||
|
if (lastUrl.StartsWith("https://s.taobao.com/search")) |
||||
|
{ |
||||
|
web.ShowDevTools(); |
||||
|
StartPage(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void StartPage() |
||||
|
{ |
||||
|
Thread t = new Thread(() => |
||||
|
{ |
||||
|
AddJquery(); |
||||
|
|
||||
|
while (true) |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
Task<JavascriptResponse> task = null; |
||||
|
|
||||
|
Application.Current.Dispatcher.Invoke(() => |
||||
|
{ |
||||
|
task = web.EvaluateScriptAsPromiseAsync("return $($('div#mainsrp-itemlist .items .item')[0]).html();"); |
||||
|
}); |
||||
|
|
||||
|
var result = task.Result; |
||||
|
|
||||
|
//判断是否加载完成
|
||||
|
if (result.Success) |
||||
|
{ |
||||
|
AddOptionDiv(); |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
t.Start(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 添加jq操作类
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
private bool AddJquery() |
||||
|
{ |
||||
|
return DoJavaScript("var script=document.createElement('script'); script.type='text/javascript'; script.src='https://code.jquery.com/jquery-1.12.4.min.js'; document.getElementsByTagName('head')[0].appendChild(script); "); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 添加操作面板
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
private bool AddOptionDiv() |
||||
|
{ |
||||
|
|
||||
|
DoJavaScript("$('div#mainsrp-itemlist .items .item .pic').before('<div class=\"myitemState falseBg\"><div class=\"stateGraydiv\"></div></div><div class=\"myopdiv\">我擦</div>')"); |
||||
|
|
||||
|
|
||||
|
///添加css
|
||||
|
return DoJavaScript(@"$('head').append('<style>
|
||||
|
.myitemState |
||||
|
{ |
||||
|
width:100%; |
||||
|
height:100%; |
||||
|
position: absolute; |
||||
|
left: 0px; |
||||
|
top: 0px; |
||||
|
} |
||||
|
.trueBg |
||||
|
{ |
||||
|
background: url(""nacollector://home/img/true.png"") no-repeat;
|
||||
|
background-size: 100% 100%; |
||||
|
} |
||||
|
|
||||
|
.falseBg |
||||
|
{ |
||||
|
background: url(""nacollector://home/img/close.png"") no-repeat;
|
||||
|
background-size: 100% 100%; |
||||
|
} |
||||
|
|
||||
|
.smallfalseBg |
||||
|
{ |
||||
|
width:78px; |
||||
|
height:78px; |
||||
|
bottom: 0px; |
||||
|
left: 0px; |
||||
|
top: unset; |
||||
|
background: url(""nacollector://home/img/close.png"") no-repeat;
|
||||
|
background-size: 100% 100%; |
||||
|
} |
||||
|
|
||||
|
.stateGraydiv |
||||
|
{ |
||||
|
width:100%; |
||||
|
height:100%; |
||||
|
background-color: rgba(85, 85, 85, 0.45); |
||||
|
} |
||||
|
|
||||
|
.myopdiv |
||||
|
{ |
||||
|
display:none; |
||||
|
} |
||||
|
.pic-box:hover .myopdiv |
||||
|
{ |
||||
|
display:unset; |
||||
|
} |
||||
|
.pic-box:hover .myitemState |
||||
|
{ |
||||
|
display:none; |
||||
|
} |
||||
|
</style>')".Replace("\n","").Replace("\r\n",""));
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 执行js
|
||||
|
/// </summary>
|
||||
|
/// <param name="js"></param>
|
||||
|
/// <returns></returns>
|
||||
|
private bool DoJavaScript(string js) |
||||
|
{ |
||||
|
js = js.Replace("\n", "").Replace("\r\n", "").Replace(System.Environment.NewLine,"").Replace("\r",""); |
||||
|
Task<JavascriptResponse> task = null; |
||||
|
|
||||
|
Application.Current.Dispatcher.Invoke(() => |
||||
|
{ |
||||
|
task = web.EvaluateScriptAsPromiseAsync(js); |
||||
|
}); |
||||
|
|
||||
|
var result = task.Result; |
||||
|
|
||||
|
//判断是否加载完成
|
||||
|
return result.Success; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
<UserControl x:Class="齐越慧眼.UserControls.ItemControl" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
|
xmlns:local="clr-namespace:齐越慧眼.UserControls" |
||||
|
mc:Ignorable="d" |
||||
|
d:DesignHeight="450" d:DesignWidth="800"> |
||||
|
|
||||
|
<Grid x:Name="grid"> |
||||
|
</Grid> |
||||
|
</UserControl> |
@ -0,0 +1,47 @@ |
|||||
|
using CefSharp; |
||||
|
using CefSharp.Wpf; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows.Data; |
||||
|
using System.Windows.Documents; |
||||
|
using System.Windows.Input; |
||||
|
using System.Windows.Media; |
||||
|
using System.Windows.Media.Imaging; |
||||
|
using System.Windows.Navigation; |
||||
|
using System.Windows.Shapes; |
||||
|
|
||||
|
namespace 齐越慧眼.UserControls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// ItemControl.xaml 的交互逻辑
|
||||
|
/// </summary>
|
||||
|
public partial class ItemControl : UserControl |
||||
|
{ |
||||
|
public ItemControl() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
Loaded += ItemControl_Loaded; |
||||
|
} |
||||
|
|
||||
|
ChromiumWebBrowser web; |
||||
|
private void ItemControl_Loaded(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
web = new ChromiumWebBrowser("nacollector://home/item") |
||||
|
{ |
||||
|
BrowserSettings = |
||||
|
{ |
||||
|
DefaultEncoding = "UTF-8", |
||||
|
Plugins= CefState.Enabled, |
||||
|
//关于跨域限制
|
||||
|
WebSecurity = CefState.Disabled |
||||
|
|
||||
|
}, |
||||
|
}; |
||||
|
|
||||
|
grid.Children.Add(web); |
||||
|
} |
||||
|
} |
||||
|
} |
After Width: | Height: | Size: 30 KiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.4 KiB |
@ -0,0 +1 @@ |
|||||
|
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>client</title><link href="/js/about.js" rel="prefetch"><link href="/css/app.66edb6c9.css" rel="preload" as="style"><link href="/css/app.css" rel="preload" as="style"><link href="/css/chunk-vendors.09af4a6b.css" rel="preload" as="style"><link href="/css/chunk-vendors.css" rel="preload" as="style"><link href="/js/app.js" rel="preload" as="script"><link href="/js/chunk-vendors.js" rel="preload" as="script"><link href="/css/chunk-vendors.09af4a6b.css" rel="stylesheet"><link href="/css/chunk-vendors.css" rel="stylesheet"><link href="/css/app.66edb6c9.css" rel="stylesheet"><link href="/css/app.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but client doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.js"></script><script src="/js/app.js"></script></body></html> |
@ -0,0 +1,2 @@ |
|||||
|
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["about"],{f820:function(t,e,n){"use strict";n.r(e);var a=function(){var t=this,e=t.$createElement;t._self._c;return t._m(0)},s=[function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"about"},[n("h1",[t._v("This is an about page")])])}],u=n("2877"),c={},i=Object(u["a"])(c,a,s,!1,null,null,null);e["default"]=i.exports}}]); |
||||
|
//# sourceMappingURL=about.js.map
|
@ -0,0 +1 @@ |
|||||
|
{"version":3,"sources":["webpack:///./src/views/About.vue?e60c","webpack:///./src/views/About.vue"],"names":["render","_vm","this","_h","$createElement","_self","_c","_m","staticRenderFns","staticClass","_v","script","component"],"mappings":"8GAAA,IAAIA,EAAS,WAAa,IAAIC,EAAIC,KAASC,EAAGF,EAAIG,eAAsBH,EAAII,MAAMC,GAAO,OAAOL,EAAIM,GAAG,IACnGC,EAAkB,CAAC,WAAa,IAAIP,EAAIC,KAASC,EAAGF,EAAIG,eAAmBE,EAAGL,EAAII,MAAMC,IAAIH,EAAG,OAAOG,EAAG,MAAM,CAACG,YAAY,SAAS,CAACH,EAAG,KAAK,CAACL,EAAIS,GAAG,+B,YCAtJC,EAAS,GAKTC,EAAY,eACdD,EACAX,EACAQ,GACA,EACA,KACA,KACA,MAIa,aAAAI,E","file":"js/about.js","sourcesContent":["var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _vm._m(0)}\nvar staticRenderFns = [function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"about\"},[_c('h1',[_vm._v(\"This is an about page\")])])}]\n\nexport { render, staticRenderFns }","import { render, staticRenderFns } from \"./About.vue?vue&type=template&id=1ae8a7be&\"\nvar script = {}\n\n\n/* normalize component */\nimport normalizer from \"!../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n \n)\n\nexport default component.exports"],"sourceRoot":""} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue