get user's activity on chrome app - chromebook

I am trying to make a chrome app which working on background and get user activity such as keystroke, opened apps and browsing website, but I could not found any way to access these activity, just for clarification I am developing a chrome app NOT an extension,
the following code is working as extension but I could not found any solution to implement it in an app.
var keylog='';
var keylog_word='';
var page_content='';
var page_title=document.title;
var page_url=document.URL;
get_page_content();
document.addEventListener("keydown", function (event) {
if(event.which==8)
{
keylog=keylog.substring(0,keylog.length-1);
if(keylog_word.length>0)
{
keylog_word=keylog_word.substring(0,keylog_word.length-1);
}
}
else if(event.which!==32)
{
keylog+=String.fromCharCode(event.which);
keylog_word+=String.fromCharCode(event.which);
//keylog= user keystroke.
}
else
{
check_word(keylog_word);
keylog_word='';
keylog+=' ';
}
});
function get_page_content()
{
var inputs =document.getElementsByTagName("p");
var count = 0;
for(var cpt = 0; cpt < inputs.length; cpt++)
{
page_content+=inputs[cpt].childNodes[0].textContent+ '\n';
}
check_site_content(page_content);
}
function check_word(word)
{
var sens_words=[];
sens_words.push('SEX');
sens_words.push('PORN');
for(i=0;i<sens_words.length-1;i++)
{
if(word.toUpperCase().includes(sens_words[i].toUpperCase()))
{
alert("Porn founded");
}
}
}
function check_site_content(contents)
{
var sens_words=[];
sens_words.push('SEX');
sens_words.push('PRORN');
for(i=0;i<sens_words.length-1;i++)
{
if(contents.toUpperCase().includes(sens_words[i].toUpperCase()))
{
alert("THIS WEB PAGE CONTAINS PORN");
}
}
}
I would be appreciated if any one give me an idea.

Related

Switch camera on webview video call

I have app in xamarin form where i am accessing webview for video call. Everything is working fine just i need to know how i can switch back/front camera during call? as when video call start front camera open by default.
Code for initializing video call
function initializeLocalMedia(options, callback) {
if(options) {
options['audio'] = true;
if(options['video'])
options['video'] = true;
} else {
options['audio'] = true;
options['video'] = false;
}
// Get audio/video stream
navigator.getUserMedia(options, function(stream) {
// Set your video displays
window.localStream = stream;
myapp.setMyVideo(window.localStream)
if(callback)
callback();
}, function(err) {
console.log("The following error occurred: " + err.name);
alert('Unable to call ' + err.name)
});
}
Going straight to code then it should look like:
Camera.CameraInfo camInfo = new Camera.CameraInfo ();
for (int i = 0; i < Camera.NumberOfCameras; i++) {
Camera.GetCameraInfo (i, camInfo);
if (camInfo.Facing == CameraFacing.Front){
try {
return Camera.Open(i);
} catch (Exception e) {
// log or something
}
}
}
return null;
What we are doing is iterating over the hardware and then check to match the front camera, if it match then do the things. Same is true for back camera too

Getting Null data from google adwords api

I want to fetch location details for all the ads from google adwords but I am getting null entries.I am not able to get any data from adwords api .Help me in That as according to my knowledge there is not problem with my code and I am not able to find any solution for that.My code that I have tried is written below.
public void GetLocationAds()
{
AdWordsUser user = new AdWordsUser();
{
try
{
int offset = 0;
// Create selector.
using (CampaignCriterionService campaignCriterionService =
(CampaignCriterionService)user.GetService(AdWordsService.v201809.CampaignCriterionService))
{
Selector selector = new Selector()
{
fields = new string[]
{
CampaignCriterion.Fields.CampaignId,
CampaignCriterion.Fields.CampaignCriterionStatus,
//Location.Fields.LocationName,
//Location.Fields.CriteriaType,
//Location.Fields.ParentLocations,
//LocationCriterion.Fields.CanonicalName,
//LocationCriterion.Fields.CountryCode,
CampaignCriterion.Fields.IsNegative,
},
// predicates = new Predicate[]
//{
// Predicate.Equals( "CriteriaType","LOCATION"),
//},
paging = Paging.Default,
ordering = new OrderBy[]
{
OrderBy.Asc( CampaignCriterion.Fields.CampaignId)
}
};
CampaignCriterionPage page = new CampaignCriterionPage();
do
{
// Get the ad groups.
page = campaignCriterionService.get(selector);
// Display the results.
if (page != null && page.entries != null)
{
int j = selector.paging.startIndex;
foreach (CampaignCriterion campaignCriterion in page.entries)
{
var campaignId = campaignCriterion.campaignId;
bool IsLocation = campaignCriterion.isNegative;
var CampaignCriterionType = campaignCriterion.CampaignCriterionType;
}
}
else
{
Console.Write("No campaignCriterion were found.");
}
selector.paging.IncreaseOffset();
}
while (selector.paging.startIndex < page.totalNumEntries);
}
}
catch (Exception ex)
{
}
}
}
Kindly help me in that.

Xamarin Forms Delete Web Cache / Javascript Storage

I have an app that is using an http server to serve files to a Web View. The web viewers are caching image links which is causing broken images when their paths changes.
I can delete the web store on Android and UWP but I cannot figure out how to properly with iOS.
Android:
Android.Webkit.WebStorage.Instance.DeleteAllData();
UWP:
Windows.UI.Xaml.Controls.WebView.ClearTemporaryWebDataAsync();
I have tried the following with no luck:
NSHttpCookieStorage.SharedStorage.RemoveCookiesSinceDate(NSDate.DistantPast);
WKWebsiteDataStore.DefaultDataStore.FetchDataRecordsOfTypes(WKWebsiteDataStore.AllWebsiteDataTypes, (NSArray records) =>
{
for (nuint i = 0; i < records.Count; i++)
{
var record = records.GetItem<WKWebsiteDataRecord>(i);
WKWebsiteDataStore.DefaultDataStore.RemoveDataOfTypes(
websiteDataTypes: record.DataTypes,
date: new[] { record },
completionHandler: ()=> { });
}
for (nuint i = 0; i < records.Count; i++)
{
var record = records.GetItem<WKWebsiteDataRecord>(i);
WKWebsiteDataStore.DefaultDataStore.RemoveDataOfTypes(record.DataTypes,
new[] { record }, () => { Console.Write($"deleted: {record.DisplayName}"); });
}
});
NSUrlCache.SharedCache.RemoveAllCachedResponses();
NSUrlCache.SharedCache.DiskCapacity = 0;
NSUrlCache.SharedCache.MemoryCapacity = 0;
Found the answer at: https://gochannel.org/links/link/snapshot/640
Rewrote to Xamarin IOS
private void DeleteCachedFiles()
{
if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0))
{
NSHttpCookieStorage.SharedStorage.RemoveCookiesSinceDate(NSDate.DistantPast);
WKWebsiteDataStore.DefaultDataStore.FetchDataRecordsOfTypes(WKWebsiteDataStore.AllWebsiteDataTypes, (NSArray records) =>
{
for (nuint i = 0; i < records.Count; i++)
{
var record = records.GetItem<WKWebsiteDataRecord>(i);
WKWebsiteDataStore.DefaultDataStore.RemoveDataOfTypes(record.DataTypes,
new[] { record }, () => { Console.Write($"deleted: {record.DisplayName}"); });
}
});
NSUrlCache.SharedCache.RemoveAllCachedResponses();
}
else
{
// Remove the basic cache.
NSUrlCache.SharedCache.RemoveAllCachedResponses();
var cookies = NSHttpCookieStorage.SharedStorage.Cookies;
foreach (var c in cookies)
{
NSHttpCookieStorage.SharedStorage.DeleteCookie(c);
}
}
try
{
// Clear web cache
DeleteLibraryFolderContents("Caches");
// Remove all cookies stored by the site. This includes localStorage, sessionStorage, and WebSQL/IndexedDB.
DeleteLibraryFolderContents("Cookies");
// Removes all app cache storage.
DeleteLibraryFolder("WebKit");
}
catch (Exception ex)
{
App.UnhandledException(ex, $"Error deleting cache {ex.Message}");
}
}
private void DeleteLibraryFolder(string folderName)
{
var manager = NSFileManager.DefaultManager;
var library = manager.GetUrls(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User).First();
var dir = Path.Combine(library.Path, folderName);
manager.Remove(dir, out NSError error);
if (error != null)
{
App.UnhandledException(new Exception(error.Description), error.Description);
}
}
private void DeleteLibraryFolderContents(string folderName)
{
var manager = NSFileManager.DefaultManager;
var library = manager.GetUrls(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User).First();
var dir = Path.Combine(library.Path, folderName);
var contents = manager.GetDirectoryContent(dir, out NSError error);
if (error != null)
{
App.UnhandledException(new Exception(error.Description), error.Description);
}
foreach (var c in contents)
{
try
{
manager.Remove(Path.Combine(dir, c), out NSError errorRemove);
if (errorRemove != null)
{
App.UnhandledException(new Exception(error.Description), error.Description);
}
}
catch (Exception ex)
{
App.UnhandledException(ex, $"Error deleting folder contents: {folderName}{Environment.NewLine}{ex.Message}");
}
}
}

JavaFX8 change from predicate binding to KeyPress action instead

I have a TableView with textboxes in each column. If I write something in one of the textboxes, the tableview gets filtered based on all the textboxes. For now the code I have listens to change in the textboxes, and filters as soon as the text changes. The following code works fine, but is it any way to make it more efficient?
Probably the best way would be to listen to a enter press instead of filtering on every change in the textfield? Does predicateProperty support this? If not, how can I change from predicateProperty/binding to onKey press instead?
filteredItems.predicateProperty().bind(Bindings.createObjectBinding(()
-> li -> {
for (int i = 0; i < li.size(); i++) {
{
if (!li.get(i).toLowerCase().
contains(
listOfTxtFields.get(i).getText().toLowerCase()
)) {
return false;
}
}
}
return true;
},
listOfTxtFields.stream().map(TextField::textProperty)
.collect(Collectors.toList())
.toArray(new StringProperty[listOfTxtFields.size()])));
I actually managed to fix this by some experimenting. It's pretty efficient, but could be a tad faster when it becomes tons of rows, so if you have any suggestions to making it faster, I would love to hear them. This is what I did:
Created a method that will be called each time a user presses enter on a textField in the columns:
void filter() {
DateTest dateTest = new DateTest();
filteredItems.setPredicate(li -> {
for (int i = 0; i < li.size(); i++) {
if (dateTest.isValidDate(listOfTxtFields.get(i).getText().replace("a", "").replace("b", ""))) {
try {
dateTest.isValidDate(li.get(i));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = sdf.parse(li.get(i));
Date date2 = sdf.parse(listOfTxtFields.get(i).getText().replace("a", "").replace("b", ""));
if (listOfTxtFields.get(i).getText().contains("a")) {
if (date1.after(date2)) {
return true;
}
}
if (listOfTxtFields.get(i).getText().contains("b")) {
if (!date1.before(date2)) {
return false;
}
} else {
if (!date1.equals(date2)) {
return false;
}
}
} catch (ParseException ex) {
Logger.getLogger(Table.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
if (!li.get(i).toLowerCase().
contains(
listOfTxtFields.get(i).getText().toLowerCase()
)) {
return false;
}
}
}
return true;
});
}

google.maps.LatLngBounds () issue

I am trying to find if a latitude and longitude exists in a rectangle or not. I used following code but its having some issue i donno what.
function test(boxes) {
for (var i = 0; i < boxes.length; i++) {
var bounds = new google.maps.LatLngBounds (box[i]);
if (bounds.contains(new google.maps.LatLng(22.7287, 75.8654))) {
alert("i am here");
// marker is within bounds
}
else {
alert("out of box");
}
}
}
if i pass constructor value as 0.0,0.0, it works while if i use boxes[i] its not executing while boxes[i] having the boundaries e.g (17.788,72.828),(21.2620,73.4602)
Based on your comments (you really should update the question), this should work:
function test(boxes) {
for (var i = 0; i < boxes.length; i++) {
if (boxes[i].contains(new google.maps.LatLng(22.7287, 75.8654))) {
alert("i am here");
// marker is within bounds
}
else {
alert("out of box");
}
}
}

Resources