greasekit

On-the-fly modifications of the links according to a set of rules (Greasekit / Javascript)

人盡茶涼 提交于 2019-12-30 13:01:52
问题 I have an HTML page with loads of entries like this: <a href="https://www.example.co.uk/gp/wine/product?ie=UTF8&asin=123456789&tab=UK_Default" class="PrmryBtnMed" I want to replace all this links so they instead are: https://www.example.co.uk/gp/wine/order?ie=UTF8&asin=1233456789 So, it's quite a complicated search and replace. These are the instructions for a human: Look at the URL. Only make a note of the number after 'asin='. (Forget everything before that and everything after that) Then,

If a button appears on a page, automatically click it

邮差的信 提交于 2019-12-23 05:28:03
问题 <a href="javascript:void(0)" class="PrmryBtnMed" id = "VERYLONGTEXT" onclick="$(this).parents('form').submit(); return false;"><span>Dispatch to this address</span></a> If I was to give instructions to a human, I would say: look for a <span>Dispatch to this address</span> link; if it appears click it. (if there is more than one such link (for example there are two) just click the first one (or any of them) I am using Greasekit, so I am looking to do this using JavaScript. Thank you! 回答1:

How can I refine this Javascript code so it IGNORES links from images

那年仲夏 提交于 2019-12-12 06:17:06
问题 This is a variation of an existing question {Please note - this question is the opposite/inverse of an existing StackOverflow question that is too complex to answer there} From the very beginning I want to make some refinement to some code from this challenge: // the new base url var base = ' https://www.example.co.uk/gp/wine/order?ie=UTF8&asin='; var links = document.getElementsByTagName('a'); for(var i = 0;i < links.length;i++){ // check each link for the 'asin' value var result = /asin=([

Using Javascript to click on a given button AND have it open in a new window

≯℡__Kan透↙ 提交于 2019-12-11 11:51:32
问题 When this page loads, I want to simulate automatically clicking the send me this thing button whilst having it open in a new window (or new tab) There will only ever be one send me this thing button on any page like that What for? This is for Greasekit on Fluid.app, which is similar to Greasemonkey. 回答1: That Button is a link and that page uses jQuery. So you can get the button like: var buyItBtn = $("a:contains('Send me this thing')"); Then modify the link to open in a new tab/window. Then

How can I refine this Javascript code to refine it so it only work on links from images (and NOT links from text)

耗尽温柔 提交于 2019-12-11 05:46:41
问题 I want to make some refinement to some code from a previous question: // the new base url var base = ' https://www.example.co.uk/gp/wine/order?ie=UTF8&asin='; var links = document.getElementsByTagName('a'); for(var i = 0;i < links.length;i++){ // check each link for the 'asin' value var result = /asin=([\d\w]+)/.exec(links[i].getAttribute('href')); if(result){ // make a new url using the 'base' and the 'asin' value links[i].setAttribute('href', base+result[1]); } } Now, instead of it acting

How can I craft a GreaseMonkey-like script to show a different page in the lower-third?

牧云@^-^@ 提交于 2019-11-29 23:20:23
问题 If you take a look at this page, there's a lot of white space in the bottom. I wish to use Greasemonkey-like script on that page, that utilises some of that white space and loads another page there (using something like an iFrame). The URL that I want to be loaded in that iFrame-type-thing (in the lower third) is always whatever View Amazon Product Page is pointing to. So, I want the code to look at the page, and find where that link points to. (As this is the bit that varies) I want the