From 07223382247a69de44558f3a24220cf7e206b28c Mon Sep 17 00:00:00 2001 From: zhangpeng Date: Tue, 4 Nov 2014 18:54:57 +0800 Subject: [PATCH 1/7] First working edition. --- .gitignore | 24 +++ README.md | 30 +++- bower.json | 32 ++++ build.sh | 7 + dist/weibo-keep-v5.user.js | 339 +++++++++++++++++++++++++++++++++++++ src/main.js | 186 ++++++++++++++++++++ src/meta.js | 17 ++ 7 files changed, 632 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 bower.json create mode 100755 build.sh create mode 100644 dist/weibo-keep-v5.user.js create mode 100644 src/main.js create mode 100644 src/meta.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..741316b --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +Thumbs.db +ehthumbs.db +[Dd]esktop.ini +$RECYCLE.BIN/ +.DS_Store +.klive +.dropbox.cache + +*.tmp +*.bak +*.swp +*.lnk + +.svn +.idea + +node_modules/ +bower_components/ +npm-debug.log + +*.zip +*.gz + +deploy.sh diff --git a/README.md b/README.md index b133535..ee7d29c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,28 @@ -weibo-keep-v5 -============= +# Weibo-Keep-V5 -[用户脚本] 尽可能强制新浪微博保持 V5 界面 +这是一个用户脚本。她的主要功能是在你浏览新浪微博网页版时,尽可能恢复 V5 界面,你懂的。 + +## 原理 + +新浪微博已经全面升级到 V6,但网友发现,新浪微博是通过某个 Cookie 值来标记版本模式的,通过修改这个值,一些主要的微博页面仍然可以以 V5 的界面运行。因此这个用户脚本所做的主要工作就是在你浏览微博时,努力保持住这个 Cookie 的值。 + +这也意味着,一旦新浪微博取消了这个触发机制,或把 V5 彻底下线,本项目也就完成历史使命了。 + +## 系统需求 + +你的浏览器需要安装特定扩展,用于管理和运行用户脚本: + +* Chrome 用户: [Tampermonkey](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo) +* Firefox 用户: [Greasemonkey](https://addons.mozilla.org/zh-CN/firefox/addon/greasemonkey/) + +## 安装 + +1. 点击 [此链接](https://rawgit.com/UserScript/weibo-keep-v5/master/dist/weibo-keep-v5.user.js) 开始安装。 +2. 如果浏览器正确安装了上述扩展,会提示安装。确认即可。 +3. 此后登录新浪微博网页版,此脚本会自动工作,无需任何额外操作。 + +*** + +## License + +[MIT License](http://www.opensource.org/licenses/mit-license.php) diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..ca39713 --- /dev/null +++ b/bower.json @@ -0,0 +1,32 @@ +{ + "name": "weibo-keep-v5", + "version": "0.1.0", + "homepage": "https://github.com/UserScript/weibo-keep-v5", + "authors": [ + "cssmagic" + ], + "description": "User script to keep Sina Weibo staying at V5.", + "main": "dist/weibo-keep-v5.user.js", + "moduleType": [ + "globals" + ], + "keywords": [ + "weibo", + "v5" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "**.sh", + "**.min.js", + "package.json", + "node_modules", + "bower_components", + "test", + "demo" + ], + "dependencies": { + "tiny.js": "*" + }, + "devDependencies": {} +} diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..3ea8588 --- /dev/null +++ b/build.sh @@ -0,0 +1,7 @@ +#!/bin/sh +cat \ + src/meta.js \ + bower_components/tiny.js/src/tiny.js \ + src/main.js \ + > \ + dist/weibo-keep-v5.user.js diff --git a/dist/weibo-keep-v5.user.js b/dist/weibo-keep-v5.user.js new file mode 100644 index 0000000..fb321d6 --- /dev/null +++ b/dist/weibo-keep-v5.user.js @@ -0,0 +1,339 @@ +// ==UserScript== +// @name Weibo-Keep-V5 +// @version 0.1.0 +// @namespace https://github.com/UserScript +// @description To keep Sina Weibo staying on V5. +// @description:zh 让新浪微博保持在 V5 界面。 +// @downloadURL https://rawgit.com/UserScript/weibo-keep-v5/master/dist/weibo-keep-v5.user.js +// @icon http://weibo.com/favicon.ico +// @grant unsafeWindow +// @run-at document-start +// @noframes +// @include http://weibo.com/* +// @include http://www.weibo.com/* +// @exclude http://weibo.com/ +// @exclude http://www.weibo.com/ +// ==/UserScript== + +/*! + * Tiny.js v0.4.0 + * https://github.com/UserScript/tiny.js + */ + +void function (root) { + 'use strict' + + //namespace + var $ = function (s, eWrapper) { + return (eWrapper || document).querySelectorAll(s) + } + + //type + $.isArray = function (arr) { + return Array.isArray(arr) + } + + //data collection + //TODO + //$.extend() + $.each = function (arr, fn, context) { + //todo: object + for (var i = 0, l = arr.length; i < l; ++i) { + fn.call(context || window, arr[i], i, arr) + } + } + $.inArray = function (arr, item) { + if (!$.isArray(arr)) return false + return arr.indexOf(item) > -1 + } + + //str + $.str = {} + $.str.include = function (so, s) { + return so.indexOf(s) > -1 + } + //TODO + //$.str.endsWith() + $.str.startsWith = function (so, s) { + return so.indexOf(s) === 0 + } + + //dom query + $.id = function (s) { + return document.getElementById(s) + } + $.cls = function (s, eWrapper) { + return (eWrapper || document).getElementsByClassName(s) + } + $.tag = function (s, eWrapper) { + return (eWrapper || document).getElementsByTagName(s) + } + + //create + $.createElem = function (s) { + return document.createElement(s) + } + $.createText = function (s) { + return document.createTextNode(s) + } + + //mod dom + //TODO + //$.after() + //$.insertAfter() + $.insertBefore = function (e, eTarget) { + eTarget.parentNode.insertBefore(e, eTarget) + } + $.before = function (eTarget, e) { + eTarget.parentNode.insertBefore(e, eTarget) + } + //TODO + //$.prepend() + //$.prependTo() + $.append = function (eWrapper, e) { + eWrapper.appendChild(e) + } + $.appendTo = function (e, eWrapper) { + eWrapper.appendChild(e) + } + $.remove = function (e) { + e.parentNode.removeChild(e) + } + + //class name + $.hasClass = function (e, s) { + return $.str.include(' ' + e.className + ' ', ' ' + s + ' ') + } + $.addClass = function (e, s) { + var so = e.className + if (!$.hasClass(so, s)) { + e.className += (' ' + s) + } + } + $.removeClass = function (e,s) { + var so = e.className + if ($.hasClass(so, s)) { + e.className = (' ' + so + ' ').replace(' ' + s + ' ', ' ').trim() + } + } + + //style + $.hide = function (e) { + e.style.display = 'none' + } + $.show = function (e) { + e.style.display = '' + } + $.css = function (e, prop, val) { + if (arguments.length === 3) { + e.style[prop] = val + } else { + e.style.cssText = prop + } + } + $.insertCSS = function (s) { + if (!s) return false + var e = $.createElem('style') + e.innerHTML = s + $.tag('head')[0].appendChild(e) + return e + } + + //event + $.on = function (e, sEvent, fn) { + e.addEventListener(sEvent, fn, false) + } + $.off = function (e, sEvent, fn) { + e.removeEventListener(sEvent, fn, false) + } + + //exports + root.$ = $ + +}(this) +void function () { + 'use strict' + + //url + var host = location.host + var path = location.pathname + var query = location.search + var req = path + query + var paramV6 = 'wvr=6' + var paramV5 = 'wvr=5' + + //cookie + var cookieKey = 'wvr' + var cookieKeyV6 = 'wvr6' + var cookieDomain = '.weibo.com' + + //util + function _setCookie(key, value, path, days, domain) { + var str = key + '=' + encodeURIComponent(value) + ';' + if (path) str += 'path=' + path + ';' + if (days) str += 'max-age=' + (60 * 60 * days) + ';' + if (domain) str += 'domain=' + domain + ';' + document.cookie = str + } + + //url + function _isV6URL(url) { + url = url || req + return $.str.include(url, paramV6) + } + function _restoreParamV5(url) { + url = url || req + return _isV6URL(url) ? url.split(paramV6).join(paramV5) : url + } + //group: 'http://weibo.com/mygroups?gid=7509&wvr=6&leftnav=1' + //comment: 'http://weibo.com/comment/inbox?topnav=1&wvr=5&f=1' + function _getPageType(url) { + url = url || req + var type = '' + if ($.str.include(url, '/mygroups')) { + type = 'group' + } else if (/\/\w+\/home\b/.test(url)) { + type = 'home' + } else if (/\/\w+\/profile\b/.test(url)) { + type = 'profile' + } else if (/\/at\/\w+/.test(url)) { + type = 'at' + } else if (/\/fav\b/.test(url)) { + type = 'fav' + } else if (/\/friends\b/.test(url)) { + type = 'friends' + } else if (/\/sorry\b/.test(url)) { + type = '404' + } + return type + } + function _getLinkPosition(url) { + var pos = '' + if ($.str.include(url, 'leftnav=1')) { + pos = 'leftNav' + } else if ($.str.include(url, 'topnav=1')) { + pos = 'topNav' + } + return pos + } + + //dom + function _isLink(elem) { + return !!( + elem && + elem.tagName && + elem.tagName.toLowerCase() === 'a' && + elem.getAttribute('href') + ) + } + function _getLink(elem) { + if (_isLink(elem)) return elem + var parent = elem.parentNode + if (_isLink(parent)) return parent + var parent2 = elem.parentNode + if (_isLink(parent2)) return parent2 + return null + } + + //weibo config + function _getWeiboConfig() { + return (unsafeWindow || window).$CONFIG + } + //$CONFIG['islogin'] ='1'; + //$CONFIG['skin'] ='skin002'; + //$CONFIG['uid'] = '1645021302'; + //$CONFIG['nick'] = 'XXXXX'; + //$CONFIG['domain'] = 'cssmagic'; + function _isDebugMode() { + var config = _getWeiboConfig() + var result = false + if (config.uid === '1645021302') { + result = true + } else if (config.domain === 'cssmagic') { + result = true + } + return result + } + //$CONFIG['pageid'] = 'myfollow'; + //$CONFIG['jsPath'] = 'http://js.t.sinajs.cn/t5/'; + //$CONFIG['cssPath'] = 'http://img.t.sinajs.cn/t5/'; + //$CONFIG['imgPath'] = 'http://img.t.sinajs.cn/t5/'; + // + //$CONFIG['pageid']='v6_content_home'; + //$CONFIG['jsPath']='http://js.t.sinajs.cn/t6/'; + //$CONFIG['cssPath']='http://img.t.sinajs.cn/t6/'; + //$CONFIG['imgPath']='http://img.t.sinajs.cn/t6/'; + function _isV6Page() { + var config = _getWeiboConfig() + var result = false + if (config.pageid) { + result = $.str.startsWith(config.pageid, 'v6') + } else { + var path = config.jsPath || config.cssPath || config.imgPath || '' + result = $.str.include(path, '/t6/') + } + return result + } + + //fn + function redir(url, srcLink) { + var isProduction = true + var debugInfo = [] + if (_isDebugMode()) { + debugInfo.push('current: ' + location.href) + if (srcLink) { + debugInfo.push('click link: ' + srcLink.getAttribute('href')) + } + debugInfo.push('redir to: ' + _restoreParamV5(url)) + isProduction = false + } + if (isProduction || confirm(debugInfo.join('\n\n'))) { + location.href = url + } + } + function restoreCookie() { + _setCookie(cookieKey, '5', '/', 1, cookieDomain) + _setCookie(cookieKeyV6, '0', '/', 1, cookieDomain) + } + function handleLink(ev) { + var elem = _getLink(ev.target) + if (elem) { + var href = elem.getAttribute('href') + var linkPos = _getLinkPosition(href) + //some links will be intercepted by "pjax", so enforce jumping + if ( + linkPos === 'leftNav' + ) { + ev.preventDefault() + redir(_restoreParamV5(href), elem) + } + } + } + function bind() { + $.on(document.documentElement, 'click', handleLink) + } + + //debug + var LOG_PREFIX = '[Weibo-Keep-V5] ' + function logInit() { + console.log(LOG_PREFIX + 'I\'m working for you!') + } + function logPageInfo() { + console.log(LOG_PREFIX + 'Current: ' + (_isV6Page() ? 'v6' : 'v5')) + if (_isDebugMode()) { + console.log(LOG_PREFIX + 'Page type: ' + _getPageType()) + console.log(LOG_PREFIX + '====== DEBUG MODE ======') + } + } + + //init + logInit() + restoreCookie() + $.on(window, 'DOMContentLoaded', function () { + logPageInfo() + if (_isV6Page()) { + bind() + } + }) + +}() diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..c0c8ee1 --- /dev/null +++ b/src/main.js @@ -0,0 +1,186 @@ +void function () { + 'use strict' + + //url + var host = location.host + var path = location.pathname + var query = location.search + var req = path + query + var paramV6 = 'wvr=6' + var paramV5 = 'wvr=5' + + //cookie + var cookieKey = 'wvr' + var cookieKeyV6 = 'wvr6' + var cookieDomain = '.weibo.com' + + //util + function _setCookie(key, value, path, days, domain) { + var str = key + '=' + encodeURIComponent(value) + ';' + if (path) str += 'path=' + path + ';' + if (days) str += 'max-age=' + (60 * 60 * days) + ';' + if (domain) str += 'domain=' + domain + ';' + document.cookie = str + } + + //url + function _isV6URL(url) { + url = url || req + return $.str.include(url, paramV6) + } + function _restoreParamV5(url) { + url = url || req + return _isV6URL(url) ? url.split(paramV6).join(paramV5) : url + } + //group: 'http://weibo.com/mygroups?gid=7509&wvr=6&leftnav=1' + //comment: 'http://weibo.com/comment/inbox?topnav=1&wvr=5&f=1' + function _getPageType(url) { + url = url || req + var type = '' + if ($.str.include(url, '/mygroups')) { + type = 'group' + } else if (/\/\w+\/home\b/.test(url)) { + type = 'home' + } else if (/\/\w+\/profile\b/.test(url)) { + type = 'profile' + } else if (/\/at\/\w+/.test(url)) { + type = 'at' + } else if (/\/fav\b/.test(url)) { + type = 'fav' + } else if (/\/friends\b/.test(url)) { + type = 'friends' + } else if (/\/sorry\b/.test(url)) { + type = '404' + } + return type + } + function _getLinkPosition(url) { + var pos = '' + if ($.str.include(url, 'leftnav=1')) { + pos = 'leftNav' + } else if ($.str.include(url, 'topnav=1')) { + pos = 'topNav' + } + return pos + } + + //dom + function _isLink(elem) { + return !!( + elem && + elem.tagName && + elem.tagName.toLowerCase() === 'a' && + elem.getAttribute('href') + ) + } + function _getLink(elem) { + if (_isLink(elem)) return elem + var parent = elem.parentNode + if (_isLink(parent)) return parent + var parent2 = elem.parentNode + if (_isLink(parent2)) return parent2 + return null + } + + //weibo config + function _getWeiboConfig() { + return (unsafeWindow || window).$CONFIG + } + //$CONFIG['islogin'] ='1'; + //$CONFIG['skin'] ='skin002'; + //$CONFIG['uid'] = '1645021302'; + //$CONFIG['nick'] = 'XXXXX'; + //$CONFIG['domain'] = 'cssmagic'; + function _isDebugMode() { + var config = _getWeiboConfig() + var result = false + if (config.uid === '1645021302') { + result = true + } else if (config.domain === 'cssmagic') { + result = true + } + return result + } + //$CONFIG['pageid'] = 'myfollow'; + //$CONFIG['jsPath'] = 'http://js.t.sinajs.cn/t5/'; + //$CONFIG['cssPath'] = 'http://img.t.sinajs.cn/t5/'; + //$CONFIG['imgPath'] = 'http://img.t.sinajs.cn/t5/'; + // + //$CONFIG['pageid']='v6_content_home'; + //$CONFIG['jsPath']='http://js.t.sinajs.cn/t6/'; + //$CONFIG['cssPath']='http://img.t.sinajs.cn/t6/'; + //$CONFIG['imgPath']='http://img.t.sinajs.cn/t6/'; + function _isV6Page() { + var config = _getWeiboConfig() + var result = false + if (config.pageid) { + result = $.str.startsWith(config.pageid, 'v6') + } else { + var path = config.jsPath || config.cssPath || config.imgPath || '' + result = $.str.include(path, '/t6/') + } + return result + } + + //fn + function redir(url, srcLink) { + var isProduction = true + var debugInfo = [] + if (_isDebugMode()) { + debugInfo.push('current: ' + location.href) + if (srcLink) { + debugInfo.push('click link: ' + srcLink.getAttribute('href')) + } + debugInfo.push('redir to: ' + _restoreParamV5(url)) + isProduction = false + } + if (isProduction || confirm(debugInfo.join('\n\n'))) { + location.href = url + } + } + function restoreCookie() { + _setCookie(cookieKey, '5', '/', 1, cookieDomain) + _setCookie(cookieKeyV6, '0', '/', 1, cookieDomain) + } + function handleLink(ev) { + var elem = _getLink(ev.target) + if (elem) { + var href = elem.getAttribute('href') + var linkPos = _getLinkPosition(href) + //some links will be intercepted by "pjax", so enforce jumping + if ( + linkPos === 'leftNav' + ) { + ev.preventDefault() + redir(_restoreParamV5(href), elem) + } + } + } + function bind() { + $.on(document.documentElement, 'click', handleLink) + } + + //debug + var LOG_PREFIX = '[Weibo-Keep-V5] ' + function logInit() { + console.log(LOG_PREFIX + 'I\'m working for you!') + } + function logPageInfo() { + console.log(LOG_PREFIX + 'Current: ' + (_isV6Page() ? 'v6' : 'v5')) + if (_isDebugMode()) { + console.log(LOG_PREFIX + 'Page type: ' + _getPageType()) + console.log(LOG_PREFIX + '====== DEBUG MODE ======') + } + } + + //init + logInit() + restoreCookie() + $.on(window, 'DOMContentLoaded', function () { + logPageInfo() + if (_isV6Page()) { + bind() + } + }) + +}() diff --git a/src/meta.js b/src/meta.js new file mode 100644 index 0000000..f31f521 --- /dev/null +++ b/src/meta.js @@ -0,0 +1,17 @@ +// ==UserScript== +// @name Weibo-Keep-V5 +// @version 0.1.0 +// @namespace https://github.com/UserScript +// @description To keep Sina Weibo staying on V5. +// @description:zh 让新浪微博保持在 V5 界面。 +// @downloadURL https://rawgit.com/UserScript/weibo-keep-v5/master/dist/weibo-keep-v5.user.js +// @icon http://weibo.com/favicon.ico +// @grant unsafeWindow +// @run-at document-start +// @noframes +// @include http://weibo.com/* +// @include http://www.weibo.com/* +// @exclude http://weibo.com/ +// @exclude http://www.weibo.com/ +// ==/UserScript== + From 171166806f0382261dc700f8fb59d3cd193d272f Mon Sep 17 00:00:00 2001 From: zhangpeng Date: Tue, 4 Nov 2014 22:26:18 +0800 Subject: [PATCH 2/7] Update project name. --- README.md | 6 ++++-- bower.json | 2 +- dist/weibo-keep-v5.user.js | 2 +- src/meta.js | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ee7d29c..4d1656a 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,14 @@ 你的浏览器需要安装特定扩展,用于管理和运行用户脚本: -* Chrome 用户: [Tampermonkey](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo) * Firefox 用户: [Greasemonkey](https://addons.mozilla.org/zh-CN/firefox/addon/greasemonkey/) +* ~~Chrome 用户: [Tampermonkey](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo)~~ + +(抱歉,暂未测试 Chrome 浏览器。) ## 安装 -1. 点击 [此链接](https://rawgit.com/UserScript/weibo-keep-v5/master/dist/weibo-keep-v5.user.js) 开始安装。 +1. 点击 [此链接](https://rawgit.com/UserScript/Weibo-Keep-V5/master/dist/weibo-keep-v5.user.js) 开始安装。 2. 如果浏览器正确安装了上述扩展,会提示安装。确认即可。 3. 此后登录新浪微博网页版,此脚本会自动工作,无需任何额外操作。 diff --git a/bower.json b/bower.json index ca39713..5bcf2ea 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "weibo-keep-v5", "version": "0.1.0", - "homepage": "https://github.com/UserScript/weibo-keep-v5", + "homepage": "https://github.com/UserScript/Weibo-Keep-V5", "authors": [ "cssmagic" ], diff --git a/dist/weibo-keep-v5.user.js b/dist/weibo-keep-v5.user.js index fb321d6..05bd3fb 100644 --- a/dist/weibo-keep-v5.user.js +++ b/dist/weibo-keep-v5.user.js @@ -4,7 +4,7 @@ // @namespace https://github.com/UserScript // @description To keep Sina Weibo staying on V5. // @description:zh 让新浪微博保持在 V5 界面。 -// @downloadURL https://rawgit.com/UserScript/weibo-keep-v5/master/dist/weibo-keep-v5.user.js +// @downloadURL https://rawgit.com/UserScript/Weibo-Keep-V5/master/dist/weibo-keep-v5.user.js // @icon http://weibo.com/favicon.ico // @grant unsafeWindow // @run-at document-start diff --git a/src/meta.js b/src/meta.js index f31f521..612c548 100644 --- a/src/meta.js +++ b/src/meta.js @@ -4,7 +4,7 @@ // @namespace https://github.com/UserScript // @description To keep Sina Weibo staying on V5. // @description:zh 让新浪微博保持在 V5 界面。 -// @downloadURL https://rawgit.com/UserScript/weibo-keep-v5/master/dist/weibo-keep-v5.user.js +// @downloadURL https://rawgit.com/UserScript/Weibo-Keep-V5/master/dist/weibo-keep-v5.user.js // @icon http://weibo.com/favicon.ico // @grant unsafeWindow // @run-at document-start From e24d697bf1c7b42ea07f384b9416effe7300eddc Mon Sep 17 00:00:00 2001 From: zhangpeng Date: Tue, 4 Nov 2014 22:33:54 +0800 Subject: [PATCH 3/7] Update readme. --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4d1656a..8f826db 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Weibo-Keep-V5 -这是一个用户脚本。她的主要功能是在你浏览新浪微博网页版时,尽可能恢复 V5 界面,你懂的。 +这是一个用户脚本。她的功能是在你浏览新浪微博网页版时,尽可能恢复 V5 界面,你懂的。 ## 原理 @@ -13,9 +13,7 @@ 你的浏览器需要安装特定扩展,用于管理和运行用户脚本: * Firefox 用户: [Greasemonkey](https://addons.mozilla.org/zh-CN/firefox/addon/greasemonkey/) -* ~~Chrome 用户: [Tampermonkey](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo)~~ - -(抱歉,暂未测试 Chrome 浏览器。) +* ~~Chrome 用户: [Tampermonkey](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo)~~ (抱歉,暂未测试 Chrome 浏览器。) ## 安装 From 5ed4852675fb8a670064721cf8cc3107f65c7a1d Mon Sep 17 00:00:00 2001 From: zhangpeng Date: Wed, 5 Nov 2014 14:13:39 +0800 Subject: [PATCH 4/7] Upgrade tiny.js to v0.4.0. --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 5bcf2ea..ef5953d 100644 --- a/bower.json +++ b/bower.json @@ -26,7 +26,7 @@ "demo" ], "dependencies": { - "tiny.js": "*" + "tiny.js": "^0.4.0" }, "devDependencies": {} } From 8b628403128f43fcfadeb2426f4c5145fa7831c0 Mon Sep 17 00:00:00 2001 From: zhangpeng Date: Wed, 5 Nov 2014 14:14:30 +0800 Subject: [PATCH 5/7] Update meta. --- src/meta.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/meta.js b/src/meta.js index 612c548..132e5b0 100644 --- a/src/meta.js +++ b/src/meta.js @@ -5,6 +5,7 @@ // @description To keep Sina Weibo staying on V5. // @description:zh 让新浪微博保持在 V5 界面。 // @downloadURL https://rawgit.com/UserScript/Weibo-Keep-V5/master/dist/weibo-keep-v5.user.js +// @updateURL https://rawgit.com/UserScript/Weibo-Keep-V5/master/src/meta.js // @icon http://weibo.com/favicon.ico // @grant unsafeWindow // @run-at document-start From d3418d1356d8bb8a4d776c83120bb3d11f99ca92 Mon Sep 17 00:00:00 2001 From: zhangpeng Date: Wed, 5 Nov 2014 14:14:49 +0800 Subject: [PATCH 6/7] Update dist file. --- dist/weibo-keep-v5.user.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/dist/weibo-keep-v5.user.js b/dist/weibo-keep-v5.user.js index 05bd3fb..85e2516 100644 --- a/dist/weibo-keep-v5.user.js +++ b/dist/weibo-keep-v5.user.js @@ -5,6 +5,7 @@ // @description To keep Sina Weibo staying on V5. // @description:zh 让新浪微博保持在 V5 界面。 // @downloadURL https://rawgit.com/UserScript/Weibo-Keep-V5/master/dist/weibo-keep-v5.user.js +// @updateURL https://rawgit.com/UserScript/Weibo-Keep-V5/master/src/meta.js // @icon http://weibo.com/favicon.ico // @grant unsafeWindow // @run-at document-start @@ -105,15 +106,13 @@ void function (root) { return $.str.include(' ' + e.className + ' ', ' ' + s + ' ') } $.addClass = function (e, s) { - var so = e.className - if (!$.hasClass(so, s)) { + if (!$.hasClass(e, s)) { e.className += (' ' + s) } } - $.removeClass = function (e,s) { - var so = e.className - if ($.hasClass(so, s)) { - e.className = (' ' + so + ' ').replace(' ' + s + ' ', ' ').trim() + $.removeClass = function (e, s) { + if ($.hasClass(e, s)) { + e.className = (' ' + e.className + ' ').replace(' ' + s + ' ', ' ').trim() } } From 43915cc329037ee36571d8287d1eb4d57188d1b7 Mon Sep 17 00:00:00 2001 From: zhangpeng Date: Wed, 5 Nov 2014 14:22:42 +0800 Subject: [PATCH 7/7] Update description. --- bower.json | 5 +---- src/meta.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index ef5953d..4e02e18 100644 --- a/bower.json +++ b/bower.json @@ -5,11 +5,8 @@ "authors": [ "cssmagic" ], - "description": "User script to keep Sina Weibo staying at V5.", + "description": "User script to keep Sina Weibo at V5.", "main": "dist/weibo-keep-v5.user.js", - "moduleType": [ - "globals" - ], "keywords": [ "weibo", "v5" diff --git a/src/meta.js b/src/meta.js index 132e5b0..cf0f714 100644 --- a/src/meta.js +++ b/src/meta.js @@ -2,7 +2,7 @@ // @name Weibo-Keep-V5 // @version 0.1.0 // @namespace https://github.com/UserScript -// @description To keep Sina Weibo staying on V5. +// @description To keep Sina Weibo at V5. // @description:zh 让新浪微博保持在 V5 界面。 // @downloadURL https://rawgit.com/UserScript/Weibo-Keep-V5/master/dist/weibo-keep-v5.user.js // @updateURL https://rawgit.com/UserScript/Weibo-Keep-V5/master/src/meta.js