|
I have made some changes to your script, which makes the site looks better -imo-;
the full script is bellow:
what do you think about the changes and is there a way to improve the script further
thanks for your good work.
####################################################################################
// ==UserScript==
// @name tomshardware.com reviews cleanup
// @description Remove ads and other non-content, greatly simplified
// @include http://www.tomshardware.com/reviews/*
// ==/UserScript==
/******* Other Suggestions
* In addition to this greasemonkey script I suggest using Adblock
* Plus, NoScript, and AutoPager.
* Adblock Plus: https://addons.mozilla.org/en-US/firefox/addon/...
* NoScript: https://addons.mozilla.org/en-US/firefox/addon/722
* AutoPager: https://addons.mozilla.org/en-US/firefox/addon/...
*
****** NoScript settings:
* I personally enable the NoScript option:
* General -> Scripts Globally Allowed (dangerous)
*
* So besides just installing NoScript, I also have to blacklist the
* sites I wanted to block. For this site that includes:
* - tomshardware.com
* - bestofmedia.com
* - kontera.com
* - revsci.net
* - clickdensity.com
* - dl-rms.com
* - tacoda.net
*
****** AutoPager settings:
* URL Pattern: http://www.tomshardware.com/reviews/*
* Link XPath: //li[@class='pagin next']/a[contains(text(), 'Next page')]
* Content XPath: //div[@class='KonaBody news-elm']
*
****** Adblock Plus settings:
* I use EasyList, plus the following filter for this site. Note that you
* have to remove the "// " at the beginning of the line:
*/
// /http://(.*\.tomshardware\.com/forum/|img\.tomsh...
// /*
var item_to_replace = $x("//div[@id='main']")[0];
var replace_with = $x("//div[@id='news-content']")[0];
var header_banner= $x("//div[@id='header']")[0];
var header_news = $x("//div[@id='header-news']")[0];
var news_index = $x("//div[@class='news-elm']")[0];
var stuff_to_remove = [
"//div[@id='footer' and @class='clearfix']", //the foot page
"//div[contains(@id, 'PAL_')]", //the shop price - generally in the 1st page of the review
"//div[contains(@id, 'PA_')]", //the shop price - generally in the 1st page of the review
"//div[@id='header-tools']", //shares-top -facebook, twiter...
"//div[@class='unitR headShare']", //shares -facebook, twiter...
];
if (item_to_replace && replace_with) {
console.clear();
item_to_replace.parentNode.replaceChild(header_banner, item_to_replace);
// console.log(header_banner
if( header_news )
header_banner.parentNode.appendChild(header_news);
if( news_index )
header_banner.parentNode.appendChild(news_index);
if( replace_with )
header_banner.parentNode.appendChild(replace_with);
//old way to recreate the page
// item_to_replace.parentNode.replaceChild(replace_with, item_to_replace);
// if( header_news_save )
// replace_with.parentNode.insertBefore(header_news_save, replace_with);
// if ( news_index_save )
// replace_with.parentNode.insertBefore(news_index_save, replace_with);
}
//remove first then replace
stuff_to_remove.forEach(
function(xpath) {
$x(xpath).forEach(
function(item) {
item.parentNode.removeChild(item);
}
);
}
);
function $x(p, context) {
if (!context) context = document;
var i, arr = [], xpr = document.evaluate(p, context, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (i = 0; item = xpr.snapshotItem(i); i++) arr.push(item);
return arr;
}
//fix layout
/*
document.getElementById("contentInside").setAttribute("style", "padding:0px 5px 0px 0px;");
document.getElementById("header-news").setAttribute("style", "padding:10px 50px 10px 25px;");
document.getElementById("news-content").setAttribute("style", "padding:1px 50px 10px 25px; font-size:110%; word-spacing:2px;");
//document.getElementById("reviewPage").setAttribute("style", "-moz-transform:scale(1.2); -moz-transform-origin:center top;");
*/
//Better way to fix the layout
GM_addStyle([ "#contentInside { padding:0px 5px 0px 0px;}",
"#header-news { padding:10px 50px 10px 25px;}",
"#news-content { padding:1px 50px 10px 25px; font-size:110%; word-spacing:2px;}",
"#news-content p { line-height:24px;}",
''].join("\n"));
####################################################################################
|