I came across an interesting way to combine CSE (Custom Search Engine) and PSE (Programmable Search Engine) and use it as a function in Sheets using the following AppScripts code:
Article Link Credits < the great Giacomo Melzi >
Code <
Now , on passing '0' as the value for 'index' parameter, the results are displayed vertically.
Can anyone change it to display the results horizontally across the same row using some code in Google App Script?
I expect someone to answer this soon, Thanks!
You should be able to do it with =TRANSPOSE(LINKEDINPROFILE(A3,0))
Related
I'm building a Chrome Extension for Google Docs, and I am trying to get the selected text from the current document being edited:
However when I trying running this code, it's returning an empty string ' ':
const docsFrame = document.getElementsByClassName('docs-texteventtarget-iframe')[0]
docsFrame.contentDocument.getSelection().toString()
There was a library called Google Docs Utils that used to be able to do this, but since Docs switched to Canvas-based rendering, the library no longer works.
EDIT:
Here's an example Google Docs to test it out
EDIT # 2:
Made some progress, found this thread with a lot of potential soltutions on it:
https://github.com/Amaimersion/google-docs-utils/issues/10
The most direct way you can do this is by using a Google Add-on script.
You'll get dropped into the Google App Scripts interface, which gives you access to Google Doc's canvas APIs, allowing you to do exactly what you're currentlty struggling to do.
Your challenge then will probably be reconciling the fact that the Google Extension store/marketplace is a different entity from the Google Add-on/Workspace marketplace.
Personally, I think you should just go all-in on writing a Google add-on. Makes life way simpler than writing a Chrome extension.
I figured out how to accomplish it with the help of the thread I mentioned above and through studying some open source code. I am not sure if I am allowed to post open source code here and to avoid licensing conflicts, I will post here the general steps I found:
Enable screen reader functionality / SVG reading. Google will add svg and rect elements to ".kix-canvas-tile-selection" that contain the text that was typed in. Look towards the second half of this thread for different solutions to enabling this.
Use $(".kix-page-paginated").get() to get the current page on Google Docs. Then use $(window).height() calculations to figure out what page the user is currently on.
After accomplishing the two above, you can use a function like so below to get the line of text
function getSelectedLineOfText(page) {
const overlaps = (a, b) => a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top
const selectionRects = $(".kix-canvas-tile-selection > svg > rect", page).get()
.map(el => el.getBoundingClientRect())
// Using text elements on that page and the selection rects, find the actual selected line of text.
const textElements $("svg > g[role=paragraph] > rect", page).get();
Note: as you can see from the function name, this can only get an entire selected line in the file. It can't get the specific text selected within a line.
So here, "name is Bob. Hi my name is Bob. Hi my name is Bob." will be returned. I was struggling to get more specific than this, so if anyone has a clue, please feel free to add / create another answer.
This question already has answers here:
Scraping data to Google Sheets from a website that uses JavaScript
(2 answers)
Closed last month.
I've used ImportHTML plenty of times before and never really had any issues with it, but for some reason, I can't seem to pull a particular table from Basketball-Reference, even though I've pulled other tables from there just fine. The table I want is the Miscellaneous Stats table lower down on this page. I've tried every index from 1 to 30 in the function, but none of them past 7 bring in any data. The function I'm using is below, with the 1 changing to whatever index I'm trying:
=IMPORTHTML("https://www.basketball-reference.com/leagues/NBA_2019.html", "table", 1)
I tried using the following code in Chrome's console to find the index of the page, but it didn't return anything:
var i = 1; [].forEach.call(document.getElementsByTagName("table"), function(x) { console.log(i++, x); });
Does anyone know how I can get this table working with ImportHTML?
Well, player0 was correct about being unable to scrape the JS table, but luckily I was able to use the URL for the embed version of that table, which works perfectly with ImportHTML.
I'm making a site for my web dev class that's supposed to act like ai, where the user asks a question about a computer issue and ideally, the main result would be a YouTube tutorial embedded on the site. So the site homepage would just be a search bar in the middle, kind of like google's homepage.
I want the question to just be entered in the search bar(I already designed it in html, css, and javascript) in the middle of the homepage and when the user presses enter, the result page should just be an embeded youtube video spanning the page width.
Realistically, if I were to work on a site like that I'd have to develop my own algorithm, but for demonstrating how the site would look, how can I go about customizing the Google CSE script to result in one embed video, or what's the closest way thing I can do to that.
Is the javascript in google CSE even customizable in that regard?
Also, open to trying any suggested, more open source search API.
I started learning HTML, CSS, and JavaScript this year btw, so I'm sorry if I'm saying anything noobish/dumb
Search engine makes use of crawlers and build indexes to show up results on searches. A search's result is entirely based on how the site was ranked based on the keywords. So in short, no you can not customize the google search result. However you can implement SEO (Search Engine Optimization) on your site in order to have your site show up in search result on any search engine. For starters, you can read more about it here: https://en.m.wikipedia.org/wiki/Search_engine_optimization
You can. Because you are not customizing how the public sees search results but only yours. However, there is no official customization method provided. You need to fake a Google by setting up a local website or using some user script technology.
I'm trying to add to my Tumblr site an additional page that displays all my posts in a random order. Effectively each time this page is loaded or refreshed the posts would be re-ordered randomly. I really want this functionality for my online art and words project as I want people to be able to discover earlier posts in an easy and fun way. I know tumblr already has an inbuilt "/random" feature but this only displays a single post, rather thank randomly ordering all posts. For reference my site is here.
I struggled with some other answers I found on this site as I'm less confident with how exactly to edit and implement changes to my specific themes javascript as opposed to just simply changing the appearance using html and css.
Any help or tips would be much appreciated,
Thanks
Kyle
You could do a cool trick with jQuery where you load a few posts from the "/random" url and then append them to the current page, using .load().
I tried this by going to "/random" on your page and running the following code. Adds five random posts to the current post list.
for (var i = 0; i < 5; i++) {
jQuery('.init-posts').append(jQuery('<div>').load('/random .init-posts article'));
}
You can apply the same logic to a Custom Page you create so long as it has a template like your single post pages.
I am having issues with a slider I have on a wordpress site. www.towntalkradio.com
1) The back button is not functioning
2) The code is supposed to call a count of all of the posts in the specified category and display all of those posts. The count is not working correctly and only part of the posts are being displayed (ex. 7 when there are 19 in the category)
I inherited this code and I have very limited experience with this setup. Any suggestions would be greatly appreciated. I apologize if I did not submit this correctly, I am new here.
Javascript
Index.php
The value you are getting is the posts per page setting.
(Settings > Reading > Blog pages show at most)
give this a go on line 9:
<?php query_posts('cat=4&order=DESC&posts_per_page=-1');?>
be sure to use wp_reset_query() after your loop.
query_posts is meant for altering the main loop, WP_Query or get_post
might be better options when running multiple loops.
http://codex.wordpress.org/Function_Reference/query_posts
http://codex.wordpress.org/Class_Reference/WP_Query