|
|
NFC/NEWS1 original page (redirect & ads section skipper) Before you start, turn off JavaScript, or use NoScript. 1) : Site's Feed 2) : Feed URL 3) : (redirect) Ad Section 4) : (redirect) Requested Article 5) : Desired Page 1) news1.co.il/Rss/ 2) news1.co.il/BringHtmlDoc.aspx?docid=174754&subjectid=1 3) news1.co.il/ PageLoad.aspx?adid=3647&pageUrl=Archive/001-D-174754-00.html?tag=14-23-554) news1.co.il/Archive/001-D-174754-00.html ?tag=14-23-555) news1.co.il/Archive/001-D-174754-00.html how to remove PageLoad.aspx?adid=3647&pageUrl= and ?tag=* ?- related threads: ?.jpg – Userscripts.org - related scripts: Block Meta Refresh – Userscripts.org YouTube Add &fmt=18 to url – Userscripts.org YouTube Video Original Page – Userscripts.org YouTube Video Original Page with Title – Userscripts.org |
|
|
// ==UserScript==
// @name ekb news1.co.il adblocker
// @namespace ekbworldwide
// @include http://www.news1.co.il/*
// ==/UserScript==
// I used tmp since I expected to remove the tag string too - but leaving the tag was simpler
if (/\/PageLoad\.aspx\?adid=\d+\&pageUrl\=/.test(location.href)) {
tmp = location.href.replace(/\/PageLoad\.aspx\?adid=\d+\&pageUrl\=/, "/");
location.href = tmp;
}
Is that what you want to do? === Edit
// ==UserScript==
// @name ekb news1.co.il adblocker
// @namespace ekbworldwide
// @include http://www.news1.co.il/*
// ==/UserScript==
var t1 = new RegExp(/\/PageLoad\.aspx\?adid=\d+\&pageUrl\=/);
var t2 = new RegExp(/\?tag=.*$/);
if (t1.test(location.href)) {
tmp = location.href.replace(t1, "/");
location.href = tmp;
}
|
|
|
Thank you ekb news1.co.il adblocker Now, how to remove news1.co.il/Archive/001-D-174754-00.html |
|
|
if (t2.test(location.href)) {
tmp = location.href.replace(t2, "/");
location.href = tmp;
}@ekbworldwide. Can you tell me why new Regexp is better?
|
|
|
Thanks jerone, but I need these two to work simultaneously - not |
|
|
@ jerone My regex stuff has been pretty simple - but if I want to test / match / replace more complex things - and change them on the fly - it's more 'exact' and far easier, simpler and clearer if the regexes are variables.
|
|
|
// ==UserScript==
// @name ekb news1.co.il adblocker
// @namespace ekbworldwide
// @include http://www.news1.co.il/*PageLoad.aspx?adid=*
// @include http://www.news1.co.il/*?tag=*
// ==/UserScript==
var lhref = location.href
var regexp = /(\/PageLoad\.aspx\?adid=\d+(\&pageUrl=.*)*)|([\&\?]tag=.*)/;
if (t1.test(lhref) || t2.test(lhref)) {
location.href = lhref.replace(regexp,'/');
}
|
|
|
Ah, brevity! [And hmmm...] |
|
|
thank you all :) |
|
|
// ==UserScript==
// @name ekb news1.co.il adblocker
// @description NEWS1 original page (redirects & ads section skipper)
// @namespace ekbworldwide
// @include http://www.news1.co.il/*
// ==/UserScript==
var t1 = new RegExp(/\PageLoad\.aspx\?adid=\d+\&pageUrl\=/);
var t2 = new RegExp(/\?tag=.*$/);
if (t1.test(location.href)) {
tmp = location.href.replace(t1, "");
location.href = tmp;
}
if (t2.test(location.href)) {
tmp = location.href.replace(t2, "");
location.href = tmp;
}
|
|
|
OffTopic:
|
|
|
how to do: 1) If |
|
|
@simon!: I think all the parts of what you've asked for are covered above, and your pseudocode would be easy enough to implement yourself. What's the problem? |
|
|
the following does not work for me var t1 = new RegExp(/\PageLoad\.aspx\?adid=\d+\&pageUrl\=/);
var t2 = new RegExp(/\?tag=.*$/);
if (t1.test(location.href)) and (t2.test(location.href)) {
tmp = location.href.replace(t2, "");
location.href = tmp;
}
else if (t1.test(location.href)) {
tmp = location.href.replace(t1, "");
location.href = tmp;
}
else if (t2.test(location.href)) {
tmp = location.href.replace(t2, "");
location.href = tmp;
}
how to tell it "if only" and "and"? |
|
|
Javascript doesn't use words as logical operators.
|
|
|
Thank, Aquilax. This script now works exactly as I desired -- I don't understand why? Whether the first "IF" will be valid or not, why the script continues to execute the other two commands??? var t1 = new RegExp(/\PageLoad\.aspx\?adid=\d+\&pageUrl\=/);
var t2 = new RegExp(/\?tag=.*$/);
if (t1.test(location.href) + t2.test(location.href)) {
tmp = location.href.replace(t2, "");
location.href = tmp;
if (t1.test(location.href)) {
tmp = location.href.replace(t1, "");
location.href = tmp;
if (t2.test(location.href)) {
tmp = location.href.replace(t2, "");
location.href = tmp;
}
}
}
|
|
|
|
|
|
explain what your code (that you just posted) does... the code now works perfectly -- but I don't understand the logic? |
|
|
First you have to know that the location object has more properties: location When you replace one of those properties, with the exception of the hash, the page will be reloaded automatically. I use some of those properties to get information directly without have to use a regular expression, and when I use it, it's only once.
|
|
|
Man, this is tough... the last time I was dealing with thing like this was 3 years ago at my High-School learning Pascal and C++ (or C# ???) Btw, I just tried your code -- it's the best, so far ;) edit: only when you switch the lines:
if (location.search.indexOf("tag=")!=-1) location.search="";
if (location.pathname=="/PageLoad.aspx") location.pathname=/pageUrl=(.*?)(?:\?|$)/.exec(location.search)[1];
|
|
|
Oops. A little flaw in mine.... here's working code I believe...
// ==UserScript==
// @name ekb news1.co.il adblocker
// @namespace ekbworldwide
// @include http://www.news1.co.il/*PageLoad.aspx?adid=*
// @include http://www.news1.co.il/*?tag=*
// ==/UserScript==
var lhref = location.href
var regexp = /(\/PageLoad\.aspx\?adid=\d+(\&pageUrl=.*)*)|([\&\?]tag=.*)/;
if (regexp.test(lhref)) {
location.href = lhref.replace(regexp,'/');
}
|
|
|
It is redirecting me to the main page and about the |
|
|
1) IfTry this... if (/\PageLoad\.aspx\?adid=\d+\&pageUrl\=/.test(location.href)) document.location.replace(location.href.replace(/\PageLoad\.aspx\?adid=\d+\&pageUrl\=/, "").replace(/\?tag=.*$/, "")) else if (/\?tag=.*$/.test(location.href)) document.location.replace(location.href.replace(/\?tag=.*$/, "")) |
|
|
thank you very much for your effort (it works fine, also), but I really think that this code is fine enough for what I wish for ^_^ edit: btw, I was wrong here 1) If |
|
|
Ok I see what you want now. Use this...
// ==UserScript==
// @name ekb news1.co.il adblocker
// @namespace ekbworldwide
// @include http://www.news1.co.il/*PageLoad.aspx?adid=*
// @include http://www.news1.co.il/*?tag=*
// ==/UserScript==
var lhref = location.href;
var pageload = /\/PageLoad\.aspx\?adid=\d+\&pageUrl=/;
var tag = /\?tag=.*/;
if (pageload.test(lhref) || tag.test(lhref)) {
location.href = lhref.replace(pageload,'/').replace(tag,'');
}
|