Created
August 28, 2011 12:42
-
-
Save tmaeda/1176625 to your computer and use it in GitHub Desktop.
ディモーラのジャンル別番組一覧から有料チャンネルを削除・除外するChrome User Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name dimora charged channel remover | |
// @namespace http://tmaeda.s45.xrea.com/td/ | |
// @description ディモーラのジャンル別番組一覧から有料チャンネルを削除するChrome User Script | |
// @include https://dimora.jp/dc/pc/* | |
// ==/UserScript== | |
(function(){ | |
console.log("dimora charged channel remover"); | |
var executeBrowserContext = function(funcOrString) { | |
try{ | |
var code = "javascript:(" + encodeURIComponent(funcOrString.toString()) + ")();"; | |
location.href = code; | |
}catch(e){ | |
console.log("error: " + e); | |
} | |
}; | |
executeBrowserContext(function() { | |
function removeChargedChannels() { | |
console.log("removing..."); | |
var xpaths = ["//dl[@class='contReservationDayText']/dd[contains(text(), 'WOWOW') or contains(text(), 'TwellV') or contains(text(), 'スター・チャンネル')]/../following-sibling::dl[1]", | |
"//dl[@class='contReservationDayText']/dd[contains(text(), 'WOWOW') or contains(text(), 'TwellV') or contains(text(), 'スター・チャンネル')]/.."]; | |
for (var i = 0; i < xpaths.length; i++) { | |
var xpath = xpaths[i]; | |
var nodes = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); | |
for (var j = 0; j < nodes.snapshotLength; j++) { | |
var item = nodes.snapshotItem(j); | |
// console.log(item); | |
item.style.display = "none"; | |
} | |
} | |
console.log("removed"); | |
}; | |
// フックする関数をいろいろ探してみたが、どれもうまく動かず。 | |
// var funcs = ["disp_gnr_P2321s"]; | |
// var funcs = ["disp_gnr_P2321", "disp_gnr_P2321s"]; | |
// var funcs = ["searchKWP2321a", "disp_gnr_P2321s"]; | |
var funcs = ["disp_gnr"]; | |
for(var i = 0; i < funcs.length; i++) { | |
var funcName = funcs[i]; | |
var orignalFunc = window[funcName]; | |
console.log("patching..." + funcName); | |
window[funcName] = function() { | |
var rtn; | |
rtn = orignalFunc.apply(null, arguments); | |
setTimeout(function (){ removeChargedChannels(); }, 1000); | |
return rtn; | |
}; | |
} | |
}); | |
} | |
)(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment