Greasemonkey - replacing one div with another - greasemonkey

I have a website with a div that looks like this:
<div id="j_id241:0:j_id269:2:j_id284:0:j_id289" class="number">Current data</div>
And I'd like to replace it with something like:
<div id="j_id241:0:j_id269:2:j_id284:0:j_id289" class="number">Replacement data</div>
The current data changes regularly, so I'd rather replace the div itself than do a search and replace for the text.
Is this possible?

Related

Make a clone of html element in _hyperscript

How to make a clone of html element in _hyperscript?
For example, I want to see a copy of a button after clicking on it. Something like:
<button _="on click put me after me">Test</button>
If you want the hyperscript to work for new nodes I currently do something like this:
<div id="test123">
<div _="on click log 'Test' then put my outerHTML after me
_hyperscript.processNode(#test123)">Copy Me</div>
</div>
<button _='on click put my outerHTML after me'>Test</button>
However, only clicking the original button produces a copy this way.

How to get href attribute using selenium for python?

I want to get the href attributes from the given HTML code so that i can go inside the link and scrape some data from it.
<div class="cb-col cb-col-67 cb-rank-plyr"> <a class="text-hvr-underline text-bold cb-font-16" href="/profiles/1643/aaron-finch" title="Aaron Finch's Profile">Aaron Finch</a> <div class="cb-font-12 text-gray">AUSTRALIA</div> </div>
<div class="cb-col cb-col-67 cb-rank-plyr"> <a class="text-hvr-underline text-bold cb-font-16" href="/profiles/10863/fakhar-zaman" title="Fakhar Zaman's Profile">Fakhar Zaman</a> <div class="cb-font-12 text-gray">PAKISTAN</div> </div>
I want to get the attributes of href and save it to a list.
You can use regular expressions to parse out thinks in the HTML such as that href tag.
Here is an article explaining that: https://medium.com/#tracy_blog/regex-and-selenium-2c5a89f23a17
To accomplish this, I would consider using get_attribute(name) over a regular expression.

Getting the value of page type form

I'm trying to add a new field named "AlternateLink" to our news page types.
Currently the "Read More" button goes to the full article page with the following:
Read More
I've updated it to:
Read More
but even with a link in the Alternate Link field (see attached image), it always links to the full article page instead of the alternate link.
I tried the same IfEmpty statement with other existing field names such as "NewsTitle" or "NewsImage" and those seem to work so the issue seems to be "AlternateLink" field name.
I created a field with the ID of "AlternateLink" as a text box. Am I missing another step to make it capture the value?
EDIT: AlternateLink is the only new thing I'm adding. All of the existing values (NewsTeaser, NewsTitle, NewsSummary, etc.) all work. Full code:
<div class="blog-post col-md-12 clearfix">
<cms:Media ID="mTeaser" runat="server" Url='<%# Eval("NewsTeaser") %>' Class="img-responsive" />
<h2 class="blog-title"><%# Eval("NewsTitle",true) %></h2>
<div class="post-info">
<i class="fa fa-clock-o"></i><%# GetDateTime("NewsReleaseDate", "MMMM dd, yyyy") %>
</div>
<p><%# Eval("NewsSummary") %></p>
Read More
<span class="hr col-md-12 col-sm-12 col-xs-12"></span>
</div>
You don't need Eval for Text/XML transformations.
Have you checked columns field of the web part, that shows news on the page? Make sure AlternateLink column is also listed there.
Have you tested using just <%#Eval("AlternateLink",true)%> to see what it returns?
Looks like your code is {%Eval("AlternateLink",true)%} when it should be {%AlternateLink%}. <%#%> is for ASPX Transformations. {%%} is for Text/XML transformations, which it looks like you are using.
Could you please try this.
Read More

A link to search bar with the cursor

I have a search bar on my web page. What do I use as the src="" if I want to make the link jump to the input section of the search bar, with the cursor blinking there too. I'm using twitter bootstrap 3 if that helps.
Try to use html label for your input.
<input type='text' id='search'/>
<label for='search'>Search</label>
Assuming that you have an input with an id of search like this:
<input type="text" placeholder="Search" class="form-control" id="search">
Then you can do this:
go to search
The preferred way to do this would be with an event handler (versus inline as I've shown above) for maintainability. That would look something like this if you're using jQuery (which I'm just assuming you are since you've marked this with a Twitter Bootstrap tag):
go to search
$(document).ready(function() {
$('.searchlink').on('click', function() {
$('#search').focus();
}):
});

Use embed variables in Expression Engine's channel tag?

I'm building a website that makes heavy use of image carousels. Each section has a different carousel with different slides.
Therefore, I've created an embed called global_embeds/image_carousel.html that contains the logic. It looks like this:
<div class="carousel">
{exp:channel:entries channel="homepage_carousel"}
<div class="slide">
<img src="{image}" alt="{title}" />
</div>
{/exp:channel:entries}
</div>
As you can see, it's a simple HTML snippet that generates a <div> for each item. The problem, however, is that I want to use an embed parameter in the exp:channel:entries tag.
I tried calling the embed in my parent template like so:
{embed="global_embeds/image_carousel" carousel_channel="homepage_carousel"}
And changing my embed template to this:
...
{exp:channel:entries channel=embed:carousel_channel}
...
But it doesn't seem to be passing the variable value through as I'd like, instead just showing all entries in my carousel regardless of channel.
Am I going about this the right way? Or is there a better way to achieve what I'm after in Expression Engine?
D'oh! Practically immediately after posting the question, I realised I can use the curly brace notation wrapped in quote marks:
...
{exp:channel:entries channel="{embed:carousel_channel}"}
...
Sorry to waste people's time.

Resources