Last active
August 26, 2015 00:34
-
-
Save pyhedgehog/92b4dd8088657ce78208 to your computer and use it in GitHub Desktop.
LJ title revert
This file contains 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 LJ title revert | |
// @id ljTitleRevert@pyhedgehog.github.com | |
// @namespace https://gist.github.com/pyhedgehog/ | |
// @description Revert recent changes on livejournal blog pages that brings ljuser to end of title. | |
// @homepage https://gist.github.com/pyhedgehog/92b4dd8088657ce78208/ | |
// @downloadURL https://gist.github.com/pyhedgehog/92b4dd8088657ce78208/raw/ljTitleRevert.user.js | |
// @updateURL https://gist.github.com/pyhedgehog/92b4dd8088657ce78208/raw/ljTitleRevert.meta.js | |
// @include http://*.livejournal.com/*.html | |
// @include http://users.livejournal.com/*/*.html | |
// @include http://*.livejournal.com/*.html?* | |
// @include http://users.livejournal.com/*/*.html?* | |
// @version 6 | |
// @grant none | |
// @run-at document-start | |
// @noframes | |
// ==/UserScript== |
This file contains 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 LJ title revert | |
// @id ljTitleRevert@pyhedgehog.github.com | |
// @namespace https://gist.github.com/pyhedgehog/ | |
// @description Revert recent changes on livejournal blog pages that brings ljuser to end of title. | |
// @homepage https://gist.github.com/pyhedgehog/92b4dd8088657ce78208/ | |
// @downloadURL https://gist.github.com/pyhedgehog/92b4dd8088657ce78208/raw/ljTitleRevert.user.js | |
// @updateURL https://gist.github.com/pyhedgehog/92b4dd8088657ce78208/raw/ljTitleRevert.meta.js | |
// @include http://*.livejournal.com/*.html | |
// @include http://users.livejournal.com/*/*.html | |
// @include http://*.livejournal.com/*.html?* | |
// @include http://users.livejournal.com/*/*.html?* | |
// @version 6 | |
// @grant none | |
// @run-at document-start | |
// @noframes | |
// ==/UserScript== | |
(function ljTitleRevert() { | |
if(!document.title) { | |
//console.log('ljTitleRevert: postpone'); | |
return window.setTimeout(ljTitleRevert, 1000); | |
} | |
//console.log('ljTitleRevert: start'); | |
//var re1 = /^https?:\/\/([^./]*)\.livejournal\.com\/[^/]*\.html(?:\?format=light)?$/; | |
//var re2 = /^https?:\/\/users\.livejournal\.com\/([^./]*)\/[^/]*\.html(?:\?format=light)?$/; | |
var re1 = /^https?:\/\/([^./]*)\.livejournal\.com\/[^/]*\.html(?:\?.*)?$/; | |
var re2 = /^https?:\/\/users\.livejournal\.com\/([^./]*)\/[^/]*\.html(?:\?.*)?$/; | |
var m = re1.exec(document.location.href); | |
if(!m) { | |
//console.log('ljTitleRevert: !re1'); | |
m = re2.exec(document.location.href); | |
} | |
if(!m) { | |
//console.log('ljTitleRevert: !re2'); | |
return; | |
} | |
var ljuser = m[1].replace(/-/g, '_'); | |
if(document.title.endsWith(': '+ljuser)) { | |
//console.log('ljTitleRevert: title.endsWith colon+'+ljuser); | |
document.title = ljuser+': '+(document.title.replace(': '+ljuser, '')); | |
return; | |
} | |
if(document.title.endsWith(' - '+ljuser)) { | |
//console.log('ljTitleRevert: title.endsWith minus+'+ljuser); | |
document.title = ljuser+': '+(document.title.replace(' - '+ljuser, '')); | |
return; | |
} | |
//console.log('ljTitleRevert: end'); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment