disabling Google instant previews and restoring cache links

General discussion about the NoScript extension for Firefox
Post Reply
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

disabling Google instant previews and restoring cache links

Post by al_9x »

Instant previews is another annoying search feature which Google will not let you turn off. Here is a surrogate that disables it:

Code: Select all

user_pref("noscript.surrogate.google_preview.sources", "@www.google.com/search");
user_pref("noscript.surrogate.google_preview.replacement", "addEventListener('DOMContentLoaded', function() { Array.forEach(document.getElementsByClassName('vsc'), function(e) { if (e.tagName === 'DIV' && e.hasAttribute('sig')) e.removeAttribute('sig'); }); }, false);");
It removes the sig attribute from each search result, which appears to be used only for previews so its removal disables the previews but doesn't seem to have side-effects.
Last edited by al_9x on Thu Sep 22, 2011 9:43 am, edited 1 time in total.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: disabling Google instant previews with a surrogate

Post by Giorgio Maone »

Thanks for sharing.
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: disabling Google instant previews with a surrogate

Post by al_9x »

Google's war on usability continues, they are rolling out a new layout that hides the cache links in the results list, showing them in the preview pane. And of course no prefs for this, as also for the preview itself. Here's a modified surrogate that: 1. disables preview, 2. kills the preview UI, 3. unhides the cache links.

For this to work, you have to disable "Google Instant" in the search prefs, otherwise paging and subsequent searches are done with ajax and the load events don't fire. It's probably possible to make this work with ajax, but I don't want instant so haven't bothered.

Code: Select all

user_pref("noscript.surrogate.google_preview.sources", "@www.google.com/search?");
user_pref("noscript.surrogate.google_preview.replacement", "addEventListener('DOMContentLoaded', function() { Array.forEach(document.getElementsByClassName('vsc'), function(e) { if (e.tagName === 'DIV' && e.hasAttribute('sig')) e.removeAttribute('sig'); }); Array.slice(document.getElementsByClassName('vshid')).forEach(function(e) { if (e.tagName === 'SPAN' && !(e.previousElementSibling && e.previousElementSibling.tagName === 'SPAN' && e.previousElementSibling.classList.contains('gl')) && e.firstElementChild) { e.classList.remove('vshid'); e.classList.add('gl'); e.insertBefore(document.createTextNode(' - '), e.firstElementChild); } }); }, true); addEventListener('load', function() {  Array.slice(document.getElementsByClassName('vspib')).forEach(function(e) { e.parentNode.removeChild(e); }); }, false);");
Mozilla/5.0 (Windows NT 5.1; rv:7.0) Gecko/20100101 Firefox/7.0
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: disabling Google instant previews and restoring cache li

Post by al_9x »

Update:

1. limit the surrogate to web search urls
2. occasionally the preview pane UI is not built yet at onload, retrying once after a delay seems to work.

Code: Select all

user_pref("noscript.surrogate.google_preview.sources", "@^https?://www\.google\.com/search\?(?!(?:.*&)?tbm=[^&]+)");
user_pref("noscript.surrogate.google_preview.replacement", "addEventListener('DOMContentLoaded', function(e) {Array.forEach(document.getElementsByClassName('vsc'), function(e) {if (e.tagName === 'DIV' && e.hasAttribute('sig')) e.removeAttribute('sig');}); Array.slice(document.getElementsByClassName('vshid')).forEach(function(e) {if (e.tagName === 'SPAN' && !(e.previousElementSibling && e.previousElementSibling.tagName === 'SPAN' && e.previousElementSibling.classList.contains('gl')) && e.firstElementChild) {e.classList.remove('vshid'); e.classList.add('gl'); e.insertBefore(document.createTextNode(' - '), e.firstElementChild);}});}, true); addEventListener('load', function(e) {var count = typeof e === 'number' ? e : 1; var els = Array.slice(document.getElementsByClassName('vspib')); if (els.length) els.forEach(function(e) e.parentNode.removeChild(e)); else if (++count <= 2) setTimeout(arguments.callee, 100, count);}, false);");
Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20100101 Firefox/8.0
Post Reply