Greasemonkey script to replace a static segment in changeable URLs of the same website - greasemonkey

Many different pages on a single (fictional) website https://www.brightideas.org contain segment '=eng' and I want to replace it, for example, with '=rus' to access its page in the corresponding language.
Example of URL: https://www.brightideas.org/gardening-skills/25/how-to-grow-a-tree?lang=eng
Segment '=eng' is always located at the end of the URLs.
Can anyone help me with a script that will accomplish this task?
Thanks in advance!

I think the easiest way to do this is:
var oldHref = window.location.href;
if(str.endsWith("eng")){
var newHref = oldHref .replace("eng", "rus");
}else{
console.log("Error in Script")
}
greets
Alex

Related

what is the best way to pass variables from a node.js file to another?

I made researches and i did not find what i want.
I have for example a Node.js file with the code:
var pseudo = req.body.pseudo;
var activation_link = generate_random_key();
message = ?
send_mail(destinataire, "subject", message);
and another independant node.js file that have:
var message = Hello {{pseudo}}. Welcome to my website. The link of activation to activate your account is: {{activation_link}}
As you can guess, I want to pass pseudo variable from the first file to the second file, ans also pass the message variable from file2 to file1.
Question: what is the best proper wat to do that ?
Thank you for helping.
The process.argv should help you.
And when you're done with that, for interprocess comunication this will help you.

How to rewrite url in codelgniter

Hello First i tell all of you that in codelgniter framework i am new and i have a problem related to my url the url looks like this
http://www.vacationplannersnetwork.com/search/name/france
but i want my URL looks like this
http://www.vacationplannersnetwork.com/france
I do search engine optimization of this website so i want this type of structure ,so if anyone knows then please help me its highly recommended.thanks in advanced.
It can be done over rerouteing.
In your APPPATH . 'routes.php' file add this line:
$route['(:any)'] = 'search/name/$1';
Since you want to have first URI segment matching your results, you would need to add other specific routes before that one. For example:
$route['contact-us'] = 'public_controller/contact_method';
$route['aboout-us'] = 'public_controller/aboutus_method';
/*
* other routes
* here
*/
$route['(:any)'] = 'search/name/$1';
Docs.
Also, don't forget to change links anchor in view files if needed (for static pages/variables).
Just use
$route['france'] = 'search/name/france';
then in <a> should bee
<a href="<?php echo base_url()?>france

How to use node.js methods in Jade template within Wintersmith

I have asked google like million times and haven't got any concrete answers... I would like to use, say, following code in the jade template... however it gives an error on the first line... Please could you point me to the right direction... Thanks in advance!!
var fs = require('fs');
fs.unlink('/tmp/hello', function (err) {
if (err) throw err;
console.log('successfully deleted /tmp/hello');
});
First, you're missing hyphens to escape your template code to JavaScript. Add a hyphen to each line for starters.
- var something = 0; // example!
Source: Jade reference
Second, #barry-johnson is right to point out your Node code probably belongs somewhere else. It looks like you're trying to clean up a directory during the build. There are other, better ways to accomplish this. I suggest taking a look at the Writing Plugins page for more info.
If that doesn't suit you, please describe in more detail what you're trying to accomplish for better guidance. I hope that helps!

How to get attached file by URL from local CouchBase-Lite?

We are trying to get an image file that has been attached to a Doc in a local CouchBase-Lite.
I'd like to be able to get this files by using the same URL syntax used for the CouchDB Remote server. (Just point to local server instead of remote)(http://wiki.apache.org/couchdb/HTTP_Document_API#Attachments)
I can seem to find how to do this.
Anyone know how? Thanks
Assuming that you are actually asking about Couchbase-Lite (aka TouchDB, ie. the embedded iOS/Android SDK) then you should look here http://couchbase.github.io/couchbase-lite-ios/docs/html/interfaceCBLAttachment.html (or the Android equivalent if that's what you're working on).
I'm not sure why you're also asking about URL syntax if that's what you're doing, so I'm not sure that is what you're doing, but hey - there's your answer. You can clarify if you were talking about something else.
This is not really an answer because I'm also looking for a solution to this. I am using CBL iOS and i want to get the local database URL to be able to get info from it.
This is what i have so far :
string[] paths = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User);
var request = new NSMutableUrlRequest();
request.Url = new NSUrl(paths[0], false);
request.HttpMethod = "GET";
var data = NSUrlConnection.SendSynchronousRequest(request, out response, out error);
if(error != null)
{
Console.WriteLine("Error in SendRequest=" + error.LocalizedDescription);
throw new HttpRequestException(error);
}
And this prints out in the console : Error in SendRequest=The requested URL was not found on this server.
the URL is something like this :
file:///Users/ME/Library/Application%20Support/iPhone%20Simulator/7.0/Applications/ABFDF-ADBAFB-SFGNAFAF/Documents/users/user

Is it possible to link a cell In Excel to a local file with a querystring?

I had wanted to put a solution onto a thumb drive or dvd to be distributed as needed. I have a couple html pages with javascript to display photos and some other info. I also have an excel spreadsheet (2003) that I wanted to link to the html page. However when I try to use a querystring I get a warning from excel stating that it "cannot open the specified file."
edit: I use javascript to parse the querystring and load a specific photo and some info.
This does not work:
=HYPERLINK("site_photos.htm?p=1", "photo 1")
This works:
=HYPERLINK("site_photos.htm", "photo 1")
Any help here would be greatly appreciated.
edit:
Okay, I've tried using ThisWorkbook.FollowHyperlink procedure using the extrainfo and not using the extrainfo parameter. This did not work. I also tried using a shell command. This also did not pass the querystring either. It looks like I will need another solution.
edit:
Here's the javascript function used to retrieve the querystring. The querystring is not in the window.location.href so this will not work when called.
function parseUrl(name)
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexStr = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexStr );
var results = regex.exec(window.location.href);
if( results == null )
return "";
else
return results[1];
}
Whether it is possible to perform the original task or not, I have opted for a different solution. I will use image controls to view the photos and other controls for navigation.

Resources